categories: computer science
Hello everyone,
Below you will find a video with a detailed explanation of the exponentiation algorithm. Its operation, time complexity, and usefulness. Below you will also find ready-made code to copy if needed.
Code:
a = int(input()) # base
n = int(input()) # exponent
def potega(a, n):
# a^n = a*a*a..(n times)
wynik = 1
for x in range(n):
wynik *= a
return wynik
print(potega(a, n))
Video:
Thank you for reading!
Read more