Skip to content

Commit ad487c1

Browse files
authoredOct 15, 2023
Create fibonacci
1 parent 52d62ac commit ad487c1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎fibonacci

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def fibonacci(n):
2+
if n <= 0:
3+
return 0
4+
elif n == 1:
5+
return 1
6+
else:
7+
return fibonacci(n - 1) + fibonacci(n - 2)
8+
9+
# Example usage:
10+
n = 10 # Replace with the desired Fibonacci number
11+
result = fibonacci(n)
12+
print(f"The {n}th Fibonacci number is {result}")

0 commit comments

Comments
 (0)
Please sign in to comment.