Jun-24-2020, 05:40 PM
Another example of recursion:
Print the series of squares of a number repeatedly until the number is over 10,000, greatest to smallest.
Print the series of squares of a number repeatedly until the number is over 10,000, greatest to smallest.
def recurse(number): if number < 10000 : recurse(number*number) print(number) return recurse(2)
Output:65536
256
16
4
2
Best non-contrived example of recursion I can think of is Towers of Hanoi.