Revision history [back]

function paramenters as sum limits

I am completely new to sage, so I am afraid that this should be a very standard well known issue. Sorry for that.

I need to define a function one of whose parameters is a limit of a sum. I tried:

d,n,i = var('d,n,i')
def N(d,n):
if n==1:
return 1
else:
return sum(N(d,i),i,1,n-1)


But sage complains with a RuntimeError. Why is that? I suppose that for some reason the parameter n from the function is not assigned to the variable limit n-1 in the sum. I this correct? How can I fix that?

 2 None FrédéricC 3595 ●3 ●36 ●72

function paramenters as sum limits

I am completely new to sage, so I am afraid that this should be a very standard well known issue. Sorry for that.

I need to define a function one of whose parameters is a limit of a sum. I tried:

d,n,i = var('d,n,i')
def N(d,n):
if n==1:
return 1
else:
return sum(N(d,i),i,1,n-1)


But sage complains with a RuntimeError. Why is that? I suppose that for some reason the parameter n from the function is not assigned to the variable limit n-1 in the sum. I this correct? How can I fix that?