Ask Your Question

Revision history [back]

Variable declaration in recursiv function

@cached_function
def Folge2(n):
    k = var('k')
    if n < 1:
        return 1
    else:
        return (-1/(n+1)*sum((binomial(n+1,k)*Folge2(k)),k,0,n-1))

print Folge2(1)

Hello. I've got a problem with this program right here.

Sage is giving back a "RuntimeError: maximum recursion depth exceeded while calling a Python object". It is likely because i'm calling Folge2(k) again with k as defined variable.

How can i avoid this?

Best regards.