[Tutor] strange recursion result

mbc2@netdoor.com mbc2@netdoor.com
Sun, 7 Jan 2001 16:01:30 -0600 (CST)

I wrote a short little program to perform a recursive calculation for me.


def rlgncount(n):
	if (n<=1):
		return 0
		return (n-1)+rlgncount(n-1)

print rlgncount(1000)

Basically it is meant to perform the following calculation where n=6:

(6-1)+(5-1)+(4-1)+(3-1)+(2-1)+(1-1) = 5+4+3+2+1+0 = 15

It works fine if I feed it numbers between 1 and 999. Anything larger than
999 doesn't work. I get an error in the "return
(n-1)+rlgncount(n-1)" line.

I must be missing something simple, but I don't see it. Does anyone have
any suggestions?