Created
June 20, 2021 20:54
-
-
Save yezz123/b83a447723c342cf366f6c1ea79c2d04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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