Python Recursivity (Fibonacci) 03-13-2013, 10:42 PM
#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!
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
Best regards.
AdrexX
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

Best regards.
AdrexX
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)


![[Image: 2YpkRjy.png]](http://i.imgur.com/2YpkRjy.png)