Created
September 26, 2024 16:01
-
-
Save sujyrokimora/c34f06084abe6bb2552d23a2c1dd0eeb to your computer and use it in GitHub Desktop.
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
| import time | |
| from turtledemo.penrose import start | |
| num1 = 0 | |
| num2 = 1 | |
| next_number = num2 | |
| def fibonacci(n): | |
| global next_number, num2, num1 | |
| count = 1 | |
| while count <= n: | |
| #print(next_number, end=" ") | |
| #print("\n") | |
| count += 1 | |
| num1, num2 = num2, next_number | |
| next_number = num1 + num2 | |
| def main(): | |
| startTime=time.time() | |
| fibonacci(int(input("How many numbers?"))) | |
| endTime=time.time() | |
| print("Done in only ",endTime-startTime," seconds!") | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment