[Tutor] Re: recursion question
Gregor Lingl
glingl at aon.at
Wed Dec 3 17:48:20 EST 2003
Lee Harr schrieb:
> def mult(m, n):
> if n < 0:
> return -mult(m, -n)
> elif n == 0:
> return 0
> elif n == 1:
> return m
> else:
> return m + mult(m, n-1)
>
>
> Now all we need to do is write a docstring and some regression tests
> and we're all set :o)
Hmm... , do you think my version would also pass your regression test?
>>> def mult(m, n):
if n < 0:
return -mult(m, -n)
elif n == 0:
return 0
else:
return m + mult(m, n-1)
Regards, Gregor
>
> _________________________________________________________________
> Protect your PC - get McAfee.com VirusScan Online
> http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
More information about the Tutor
mailing list