Hello

As en exercise I wrote the following function:


def recursfac(x,carryover=1):
    print 'x:',x,'carryover:', carryover
    if x > 1:
        carryover *= x
        recursfac(x-1, carryover)
    else:
        return carryover

print recursfac(3)

Very much to my surprise I get the following output:

x: 3 carryover: 1
x: 2 carryover: 3
x: 1 carryover: 6
None

Where did I go wrong?

Kind regards
Dominik Danter
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to