Return to the home page.

The Ultimate Windows Math Toolbox

 

bullet Ver 3.0.697
23 June 2008
bullet Free support
bullet Only $44.85 (US)
(Professional)
Click to buy UltimaCalc Professional
bullet Only $34.85 (US)
(Standard)
Click to buy UltimaCalc Standard.

bullet Free download

<<< Prev  Next >>>

 

Prime Numbers

A prime number is defined as any integer (a whole number) greater than 1, which will only divide by itself and 1, with no remainder.

Two functions work with prime numbers:

prime(n) gives the nth prime number. So prime(1) gives 2.

factor(n) gives the smallest factor of n. So factor(15) gives 3.

The prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 and so on. These are the first 12 prime numbers. What is the next prime number? Evaluate the expression prime(13) and UltimaCalc will tell you it is 41.

Any number greater than 1 is either a prime number or it has at least two factors which are prime. Suppose you are wondering whether 91 is a prime number. Evaluate factor(91) and UltimaCalc responds with 7. This is the smallest prime factor of 91. If you try factor(97), UltimaCalc responds with 97, the number you started with – the smallest prime factor of 97 is 97, so 97 must be a prime number.

If you want to know how many prime numbers are known to UltimaCalc, evaluate prime with a very large argument, such as prime(1e12). The resulting error message will tell you how many primes UltimaCalc knows.

UltimaCalc stores information about all the prime numbers it knows in a file. When it starts up, UltimaCalc reads the first few thousand primes into memory and keeps them there. If UltimaCalc needs to know other primes, it reads in a chunk of the file that contains the information it needs. This technique allows UltimaCalc to have reasonably fast access to prime numbers, without consuming large amounts of the computer’s RAM memory.

If this file is lost or deleted, UltimaCalc will automatically rebuild a file consisting of the first 100,000 primes. This takes little time, and UltimaCalc will not bother to disturb you to tell you when it has finished.

If you want more prime numbers, you can open the Options window (at the menu item Options / Other) and choose how many you want, up to just over 200 million of them. UltimaCalc will then calculate the new primes in the background and let you know when it has finished. Meanwhile, you can still use UltimaCalc, including the prime number functions, but they will fail if the prime number needed has not been calculated yet. In this case, just try again later.

Caution

It is best to not stop UltimaCalc before it has calculated its batch of prime numbers, as this can cause the file to become corrupted. Unless you are using a very slow computer, the process will only take a few minutes at most. Also, if you have more than one instance of UltimaCalc running on your computer, do not ask both instances to create new primes at the same time.