Solve problem "Exponentiation" online - Learn Python 3 - Snakify

Problem «Exponentiation» (Medium)


Statement

Given a positive real number \( a \) and a non-negative integer \( n \). Calculate \( a^{n} \) without using loops, ** operator or the built in function math.pow(). Instead, use recursion and the relation \( a^{n} = a \cdot a^{n-1} \). Print the result.

Form the function power(a, n).


In all the problems input the data using input() and print the result using print().



Saved solutions

Tests

Input Correct answer Result
2
3
8
2
2
4
2
1
2
2
4
16
2
5
32
2
6
64
2
7
128
2
8
256
2
9
512
2
10
1024
2
15
32768
2
0
1
3
1
3
3
2
9
3
3
27
3
4
81
3
5
243
3
10
59049
3
0
1
1.1414
2
1.30279
1.5
10
57.665