I need to define a function called rec_range(n) which takes a natural number and returns a TUPLE of numbers up to the number n.
i.e. rec_range(5) returns (0,1,2,3,4)
This is nice and concise, I think:
def rec_range(n):
if not n <= 1: return rec_range(n-1) + (n-1,)
return (0,)
Basically you recurse downwards until you reach 1, and for each recursion add one less than the number that you just recursed on position wise to your tuple.
Outputs:
>>>rec_range(4)
(0, 1, 2, 3)