Skip to content

Instantly share code, notes, and snippets.

@jalcoding8
Created November 16, 2022 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jalcoding8/ed172b039898ffa11988e9ae8a5a0f16 to your computer and use it in GitHub Desktop.
Save jalcoding8/ed172b039898ffa11988e9ae8a5a0f16 to your computer and use it in GitHub Desktop.
Coding_Challenge/Fibonacci_Finder
def fib_finder(n):
# Write your code here
if n <= 0:
ValueError("Number must be greater than zero.")
elif n == 1:
return 0
elif n == 2:
return 1
fibs = [0, 1]
for i in range(2, n):
fibs.append(fibs[-1] + fibs[-2])
print(fibs)
return fibs[-1]
print(fib_finder(1))
print(fib_finder(2))
print(fib_finder(6))
print(fib_finder(13))
Output
0
1
[0, 1, 1, 2, 3, 5]
5
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]
144
Test cases
All tests passed!
Submit your solution when you're ready. Once you submit, all code will be saved as final.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment