Recursion

Erik Max Francis max at alcyone.com
Mon Jan 1 17:48:25 EST 2001


Bob Calco wrote:

> 1. Why the vast difference between the languages? Is this apparent
> limitation in Python deliberate, or the consequence of some other
> design
> decision?

Python is strongly typed, as opposed to Perl which is weakly typed.  In
Perl all numbers are stored in floating point (whether you realize it or
not).  In Python you're only dealing with ints.  Python has a "long"
type for arbitrary precision integers; you should be using that instead.
(If you're serious about a factorial implementation, you wouldn't use
recursion, either.)

In Perl you'd be using the default floating point implementation, which
is obviously not ideal for calculating a large integer (floating point
numbers have a limited precision).  In Python, with longs, the integers
can get as large as you like and Python will still support them to full
precision.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ Never had very much to say / Laugh last, laugh longest
\__/ Des'ree
    Kepler's laws / http://www.alcyone.com/max/physics/kepler/
 A proof of Kepler's laws.



More information about the Python-list mailing list