Fibonacci
A couple of simple Fibonacci functions in Python.
#a and b are the starting numbers and count is how many numbers in the sequence to generate def fib(a, b, count): if count>0: print a fib(b, a+b, count-1) #finds the sum of all the fibonacci numbers in a range. a and b are the starting numbers and count is how many numbers in the sequence to generate and currentSum is the sum so far (set to 0 when calling) def fibsum(a, b, count, currentSum): if count>0: currentSum+=a return fibsum(b, a+b, count-1, currentSum) else: return currentSum;

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Download this code in plain text format here