Skip to content

Instantly share code, notes, and snippets.

@yezz123
Created June 20, 2021 20:54
Show Gist options
  • Save yezz123/b83a447723c342cf366f6c1ea79c2d04 to your computer and use it in GitHub Desktop.
Save yezz123/b83a447723c342cf366f6c1ea79c2d04 to your computer and use it in GitHub Desktop.
def nth_fibonacci(n):
a = 0
b = 1
if n < 0:
print("Incorrect input")
elif n == 0:
return a
elif n == 1:
return b
else:
for i in range(2, n):
c = a + b
a = b
b = c
return b
def factorial(n):
fact = 1
if n == 0:
return fact
else:
for num in range(2, n+1):
fact *= num
return fact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment