How can I use recursion to find increments of a number in python? -


i have following code, doesn't work when run it. return like: [5,10,15,20] if inputed value n 4. advice appreciated.

def multiplerecursive(n):     multiples=[]     if n==0:         multiples.append(n)     else:         total=5*multiplerecursive(n-1)         multiples.append(total)     return multiples 

a trivial version is:

def mr(n):     if n == 0:         return []     return mr(n-1) + [5*n] 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -