VOOZH about

URL: https://www.geeksforgeeks.org/dsa/power-in-mathematics/

⇱ Power in Mathematics - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Power in Mathematics

Last Updated : 11 Jul, 2025

The power of a number says how many times to use the number in a multiplication. Powers are also called Exponents or Indices. For example, 8^2 could be called "8 to the power 2" or "8 to the second power", or simply "8 squared". 
 

👁 Image


Some interesting fact about Power : 
 

  1. If the indices is 1, then you just have the number itself. For example, 5^1 = 5
  2. If the indices is 0, then you get 1. For example, 5^0 = 1
  3. Exponents make it easier to write and use many multiplications
  4. Negative exponent means how many times to divide one by the number.For example, 5^-1 = 1 /5 = 0.2


How we check if a number is power of y for a given integer x ?
Naive solution: 
Given two positive numbers x and y, check if y is a power of x or not.
Examples : 
 

Input: x = 10, y = 1
Output: True

Input: x = 10, y = 1000
Output: True

Input: x = 10, y = 1001
Output: False


Approach : A simple solution is to repeatedly compute powers of x. If a power becomes equal to y, then y is a power, else not. 
 

Output: 
 

True
False
True
False


Time complexity of above solution is O(Logxy)

Auxiliary Space: O(1)
Basic Program related to Power : 
 


More problems related to Powers : 
 


Recent Articles on Power! 
 

Comment
Article Tags:
Article Tags: