This commit is contained in:
Armen Vartan
2014-12-01 12:17:43 -05:00
parent 89e5a5f4b0
commit b9a8397f34
124 changed files with 2918 additions and 0 deletions

View File

@ -0,0 +1,14 @@
##The Fibonacci Sequence
The fibonacci sequence are the numbers in the following integer sequence:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...and so on
Write a function that detects whether its input is a fibonacci number or not.
Make sure the assert statements all pass. Write two of your own Python assert statements.
Resources
=========
[Fibonacci Numbers](http://en.wikipedia.org/wiki/Fibonacci_number)
[Fibonacci in Nature](http://jwilson.coe.uga.edu/emat6680/parveen/fib_nature.htm)

View File

@ -0,0 +1,16 @@
def fibonacci(num):
pass
# FOR TESTING ONLY
import random
def random_fibonacci():
fib = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025]
return random.sample(fib, 1)[0]
assert(fibonacci(random_fibonacci()) == True), "Random Fibonacci number should return true"
assert(fibonacci(50) == False), "50 should return false"
assert(fibonacci(97450) == False), "50 should return false"
assert(fibonacci(1) == True), "1 should return true"
assert(fibonacci(7540113804746346429) == True), "A massive number in sequence should return true"