[Edu-sig] More Lesson Planning (correction)

Kirby Urner pdx4d@teleport.com
Fri, 04 Feb 2000 20:37:58 -0800

>[2] I notice the Scheme books do a 'tail-recursive' 
>    version of factorial that doesn't require two 

Correction:  this should have been 'fibonacci', not
factorial.  Like, in Python I might write:

def fibbo(n):
    # return nth fibonacci number    
    if n == 0: return 0
    elif n == 1: return 1
    else: return fibbo(n-1) + fibbo(n-2)

but that sets up two separate recursive calls.  There's 
a "tail recursive" alternative which sets up an inner 
function accepting two args that I saw in a Scheme 
text.  Wondering if there's a Python equivalent. 
Can internal defs be recursive, is the first question?
Yes, I tried.  But I'm no Python guru.