BIGFAC.BAS
February 2000 by Marc Kummel aka Treebeard.
Contact mkummel@rain.org, http://www.rain.org/~mkummel/
What is BIGFAC.BAS?
--------------------
BIGFAC is a small BASIC program I wrote to find the factorial of big
numbers up to 10,000,000! and factor the result. 10000000! is
1x2x3x...x10000000, a truly huge number of 65+ million digits! BIGFAC
uses a disk file to store working results so it's not limited by string
space. This program is modified from source code posted to
comp.lang.basic.misc by Derek Ross on 10 Oct 1999. Thanks, Derek! All
calculations are saved in the text file BIGFAC.TXT. There is some disk
thrashing with huge numbers, and you'll want to flush this file now and
then as it gets quite huge.
I've only run BIGFAC to 10,000! so far. It does 100! in no time at all,
but it takes about an hour to figure the 35,660 digits of 10,000 factorial.
It's pretty fast since it does all the arithematic in base 10,000,000.
Basically, this breaks up the big numbers into "bins" that can be
represented by 32 bit long integers in the BASIC compiler. After each
multiplication, any carry is moved to the next bin, just like ordinary
multiplication. It uses the hard drive to store intermediate results, so
there's no limit on size, but I don't like the way it thrashes my hard drive
when working with big numbers.
For more info on the Factorial function, check out my Stumper 100! at
at . There's advanced
discussion of the math at Eric Weisstein's World of Mathematics site at
.
For more big number arithmatic code in BASIC, check out my BIGNUM and BNC
programs available at Treebeard's Basic Vault at
.
Using BIGFAC.BAS
-----------------
BIGFAC is a simple DOS program. Run it in DOS, or a Command session in
Windows. It waits for you to enter a number to find the factorial of.
Just press return to exit. All results are saved to the text file
BIGFAC.TXT.
The Files:
-----------
I wrote this program to solve a stumper. You'll have to study the source
code for more info. I wrote it using MS Basic PDS v7.10, but it should
work with any version of QBasic, QuickBasic, or PDF.
BIGFAC.EXE DOS executible to partition a number
BIGFAC.BAS BASIC source code
BIGFAC.TXT Text file created to hold results
BIGFAC.NUM Working file created to hold intermediate results
BIGNUM.TXT A few big factrials
README.TXT This file
TBVAULT.TXT Treebeard's Basic Vault info
Conditions:
------------
This program and source code are yours to use and modify as you will, but
they are offered as freeware with no warranty whatsoever. Give me credit,
but do not distribute any changes under my name, or attribute such changes
to me in any way. You're on your own!
If you find this program or code useful, then let me know what you do with
it, as a courtesy to a fellow programmer who still hacks for fun and glory.
Any suggestions or comments will be much appreciated.
Send comments and fixes to:
Marc Kummel aka Treebeard
mkummel@rain.org
http://www.rain.org/~mkummel/
http://www.treebeard.org/
For more interesting Basic software with source code, check out Treebeard's
Basic Vault at .