| | |
Python can handle Very Large Numbers
Scientists and deficit spenders like to use Python because it can handle very large numbers. I decided to give it a test with factorials. Factorials reach astronomical levels rather quickly. In case you can't quite remember, the factorial of 12 is !12 = 1*2*3*4*5*6*7*8*9*10*11*12 = 479001600, that is 479 million and some change! After that languages like C++ start to fizzle quickly! At !16 we get past the nations debt. Python can handle that and more! I stopped at !69 only because the display started to wrap the line. The result has 98 digits in it, I thought I made my point anyway.
# check the numeric range of Python with huge factorials # factorial(69) still checks out accurately! Has 98 digits in it! # 171122452428141311372468338881272839092270544893520369393648040923257279754140647424000000000000000 # tested with Python24 vegaseat 01aug2005 def getFactorial(n): """returns the factorial of n""" if n == 0: return 1 else: k = n * getFactorial(n-1) return k for k in range(1, 70): print "factorial of", k,"=", getFactorial(k)
Similar Threads
- Large numbers (C)
- How to use find to handle large number of files (Getting Started and Choosing a Distro)
- how to handle large lists? (Python)
- Large Numbers (PHP)
- variable to handle large integer (C)
| Thread Tools | Search this Thread |
abrupt alarm ansi anti apache approximation array assignment backend beginner binary bluetooth builtin calculator character cmd converter countpasswordentry curved customdialog cx-freeze dan08 data decimals dictionary directory exe file float format function gnu halp heads homework ideas inches input itunes java leftmouse library line lines linux list lists loop module mouse mysqlquery number numbers numeric output parsing path phonebook pointer prime programming push py2exe pygame python random recursion redirect schedule screensaverloopinactive script scrolledtext slicenotation software sqlite ssh statictext statistics string strings sudokusolver terminal text thread time tlapse tuple twoup ubuntu unicode urllib urllib2 variable ventrilo webservice wikipedia wordgame write wxpython xlib



