Last active
December 6, 2017 08:01
-
-
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
This file contains hidden or 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
| #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