Skip to content

Instantly share code, notes, and snippets.

@rudrathegreat
Created November 24, 2018 04: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 rudrathegreat/7f151fcdc5c61eb2f71fcfe5a2b5a915 to your computer and use it in GitHub Desktop.
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 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