Skip to content
Permalink
Browse files
Created some simple recursive functions
  • Loading branch information
hortonr6 committed Jul 19, 2019
1 parent 0f41785 commit f419985e56bc615f3f7192bfc1bd285da369296f
Showing 1 changed file with 22 additions and 0 deletions.
@@ -0,0 +1,22 @@
def recCount(x):
if x == 0:
print("BOOOOM!")
return None
else:
print(x, ".......")
recCount(x - 1)

def power(num, pwr):
if pwr == 0:
return 1
else:
return num * power(num, pwr - 1)

def factorial(num):
if num == 1:
return 1
else:
return num * factorial(num - 1)

print("3 to the power of 7 is:", power(3, 7))
print("7! is:", factorial(7))

0 comments on commit f419985

Please sign in to comment.