Skip to content

Instantly share code, notes, and snippets.

@chaewonkong
Last active December 6, 2017 08:01
Show Gist options
  • Select an option

  • Save chaewonkong/6c5622b55822c35ecbd2de196b857e3b to your computer and use it in GitHub Desktop.

Select an option

Save chaewonkong/6c5622b55822c35ecbd2de196b857e3b to your computer and use it in GitHub Desktop.
Fibonacci Sequence: Getting integer input and prints nth fibonacci number as an output
#Fibonacci Sequence Study
#This program will find out 2 things:
#1)Whether the given number is in fibonacci sequence,
#2)If it is in the Fibonacci sequence, then shows the nth
n = int(input('Please enter an integer:'))
def fibo(n):
if n in [1,2]:
return 1
elif n ==0:
return 0
else:
return fibo(n-1) + fibo(n-2)
print(fibo(n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment