Login Register






Python Recursivity (Fibonacci) filter_list
Author
Message
Python Recursivity (Fibonacci) #1
So I have made this recursive function which takes a user-input, and then multiply the input with all positive natural integers below the input (Also know as the Fibonacci sequence). In short, the user-input determines the max range for the Fibonacci sequence and calculates the product, what do you think? could it be written more simple? - Let me hear your ideas!

Spoiler:
Code:
string = '' def Fibonacci(n): global string if n == 1: string += '1' return 1 else: string += str(n) + ' * ' return n*Fibonacci(n-1) while 1: print str(Fibonacci(input('Enter a number: '))) + ' = ' + string raw_input('Press enter to type again...') print '' string = ''



I was also thinking about doing some tutorials in python, starting of easily with arithmetic operators and then continue to more advanced stuff later on, like a long tutorial with examples in every little part.

Hopefully this could help some beginners to get even better, let me hear what you think! I will not waste any time if the community does not need it, so leave a comment Smile

Best regards.

AdrexX

Reply





Messages In This Thread
Python Recursivity (Fibonacci) - by AdrexX - 03-13-2013, 10:42 PM