Skip to content

Commit

Permalink
Merge pull request tarunsinghofficial#501 from akhilsachan/main
Browse files Browse the repository at this point in the history
Create akhil-sachan.md
  • Loading branch information
tarunsinghofficial authored Oct 20, 2020
2 parents feb8577 + bf10bd2 commit 198727a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Power-of-number-by-recursion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Python code to find the power of a number using recursion

# defining the function to find the power
# function accpets base (x) and the power (y)
# and, return x to the power y
def pow(x, y):
if y == 1:
return x
else:
return pow(x, y-1) * x

# main code
if __name__ == '__main__':
x = 2 #base
y = 3 #power
result = pow(x, y)
print(x," to the power ", y, " is: ", result)

x = 10 #base
y = 3 #power
result = pow(x, y)
print(x," to the power ", y, " is: ", result)

x = 12 #base
y = 5 #power
result = pow(x, y)
print(x," to the power ", y, " is: ", result)
4 changes: 4 additions & 0 deletions akhil-sachan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Akhil Sachan
Photo: https://ibb.co/cbh7JMF
Location: INDIA
Github: https://github.com/akhilsachan

0 comments on commit 198727a

Please sign in to comment.