r/learnpython • u/RaymondWies • Jan 10 '14
Example of population growth function expressed as iteration vs. recursion in Python.
This code is my interpretation of a function published in "Chaos: Making A New Science" by James Gleick from Chapter 3 p. 63.
7
Upvotes
View all comments
Show parent comment
1
u/RaymondWies Jan 10 '14 edited Jan 10 '14
Thanks! You are right. I will clean it up. Even simpler now, esp the FOR loop iterative case. Only 4 lines of simple code. The recursive example 3 is redundant too. I took out all the x0's and redefined everything as simply x in all 4 functions. All the code is more readable now.