Created
November 24, 2018 04:41
-
-
Save rudrathegreat/7f151fcdc5c61eb2f71fcfe5a2b5a915 to your computer and use it in GitHub Desktop.
A Program Designed to Prove That the BBC Microbit Is Indeed Computing the Fibonacci Sequence
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
''' | |
This program is designed to porve that | |
the BBC Microbit is actually calculating the | |
Fibonacci Sequence. The code for computing | |
Fibonacci Sequence up to a specific number | |
of numbers inthe sequence can be found using | |
the following link - | |
https://gist.github.com/rudrathegreat/bfafd7af975f0737458c8d63c0eda84d | |
According to my BBC Microbit, the maximum number | |
of numbers it can calculate before crashing is | |
9000, which is a new world record, unofficially. | |
Any higher than that and the BBC Microbit raises | |
a Memory Error because it has ran out of memory | |
to calculate further. | |
''' | |
import time | |
start_time = time.time() | |
def fibonacci(x): | |
a = 0 | |
b = 1 | |
for i in range(x-2): | |
c = b | |
b = a + b | |
a = c | |
return b | |
numbers_to_generate = 500 | |
numbersGenerated = fibonacci(numbers_to_generate) | |
end_time = time.time() | |
time = end_time - start_time | |
print(numbersGenerated) | |
print('run time: ' + str(time) + 's') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment