Variable declaration in recursiv function [closed]

asked 2018-12-23 00:37:58 +0100

Quotenbanane gravatar image
@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.

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by tmonteil
close date 2018-12-23 02:10:58.283228