Free C-programs for Unix, Linux and
console mode under Windows 98/XP/7/8/10
Back to Stefan's home page
These C-programs are developed by Stefan Spännare and are free to copy.
Read the header of each C-program source code for instructions.
Compiling instructions and help for the programs.
2. Download SSCLN
3. Download SSPROG Updated!
4. π, Chudnovsky or Ramanujan Updated!
5. e=exp(1) and ln(2)
6. Euler C, γ
7. Γ(1/3) and Γ(1/4)
8. Catalan's constant G
9. Apery's constant ζ(3)
11. A program to calculate some mathematical constants to large precision
12. Other e=exp(1) calculating programs
13. Fast hexadecimal e=exp(1) calculating programs
14. Digit statistics
16. Prime numbers
18. Programs for fun
2. The web page Fast Algorithms and the FEE Method, by Ekatherina A. Karatsuba.
3. The web page The Karatsuba Method 'Divide and Conquer', by Ekatherina A. Karatsuba.
4. The article "Fast evaluation of transcendental functions", Problems of Information Transmission,
vol. 27, (1991), p. 339-360,
by Ekatherina A. Karatsuba.
5. The article "Fast multiprecision evaluation of series of rational numbers", by Bruno Haible and Thomas Papanikolaou, 1997:
6. Some of the programs now use a very fast FFT by Takuya Ooura:
7. The web page CLN - Class Library for Numbers, by Bruno Haible et. al.
8. The documentation "Programs to Calculate some Mathematical Constants to Large Precision", by Stefan Spännare, September 2007:
The short C++ programs in this package use very fast functions in the CLN
(and GMP) packages to calculate some mathematical constants. The results
are interesting in themselves but can also be used to verify calculations
with other programs.
All the programs in this package work fine in DOS (or CMD) mode under Windows XP,
2000 and probably also Windows 98. And also Windows 7 32-bit. And of course under
Linux if you compile the source code.
The Windows executables compiled with DJGPP under 32-bit
Windows XP DO NOT work on 64-bit Windows operating systems! The author
will investigate the best way how to solve this problem to the next release of
the package. Until then only version 2.26 (with 32-bit executables) is available
Important note November 5 2015.
A bit late perhaps, but the author recommends that you use
the free Microsoft Visual Studio 2015 (that includes C and C++) to compile these C-programs
in Windows. It works very well and generates very fast code. On my ASUS notebook with
quad Intel i7 2670QM CPU sspi calculates π with about 2 million decimals in 19.04 seconds
on one CPU core. Under Tools in MS Visual Studio C++ you can open a console window
and compile the program with the following line. Some include files may be removed
(or perhaps added) in the C-program code to fit this compiler.
cl -O2 -o sspi.exe sspi.c fftsg_h.c -lm
The Unix and Linux package now includes cbrun2l32, cbrun2l64, cbrun3l32
and cbrun3l64 executables for Linux (in the PRIMES directory) compiled using
Intel C/C++ 11.1 (icc) with the "-pc80" (long double) option. Versions are
available for both 32-bit and 64-bit Linux. The executables are compiled for
Intel Pentium 3, Pentium 4 and Core 2 Duo processors. Some of them work
well also on AMD CPUs.
June 19 2012. Here is now available an updated version of sspi.c called sspi2.c. Most
of the new work was done already January 2010. Parts of the code (the procedures) now
have "how to use" comments and ladd, lsub, bigadd, bigsub and some other procedures
have temporary variables so that both input and output variables can be the same. The rest
of the code could benefit somewhat from that, but it is not changed. The programs on
this web-page are now mostly of historical interest, because much faster programs for
mathematical constants computations exist on the web that also use multi core support.
This program uses some (not that fast) AGM based algorithms.
The program uses a very fast FFT (fftsg_h.c) by Takuya Ooura. Many thanks to him!
Slower floating point method, probably numerically stable:
Long long int (64 bit) integer method, numerically stable:
Chose the program that is fastest on your computer:
The following program is also needed for the final result:
Programs to convert from hexadecimal to decimal:
Why not check if the digits seem to have a normal distribution:
This program calculates large factorials (n!) exactly:
All the prime number programs use a segmented implementation of Eratosthenes sieve.
They are very fast and require very little memory.
These two programs works theoretically for n ≤ 253-1 ≈
This program calculates (and print) all primes below n.
This program makes a table of the number of primes and twin primes below n.
These programs calculate Bruns constant and the Twin prime constant and the number
of primes and twin primes below n. Works theoretically for n ≤ 264-1 ≈ 1.8·1019.
(using long double numbers). The programs cbrun2l* and cbrun3l* are significantly
faster than cbrunl for large n (≥ 1010).
Some results from the programs.
Quick sort (very fast, non recursive and recursive):