Tool to search for prime numbers located before a number, or the nth previous prime number smaller than/inferior to a given number.
Previous Prime Number - dCode
Tag(s) : Arithmetics
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
For a given number $ N $, the previous prime number is the smallest number strictly less than $ N $ which is a prime number.
No mathematical formula allow an automatic calculation of the prime number preceding any number N (less than N). dCode performs primality tests on numbers below the requested number until a prime number is found.
Example: The largest prime number that precedes 100 is 97
Example: The 10th prime number preceding 1000 is 937 (so there is a list of 9 prime numbers between 938 and 999 included)
The number $ N $ must be a positive real number superior to 3.
The largest number with $ n $ digits is $ 10^n -1 $ (that is always a multiple of 9), so the largest prime number with $ n $ digits is the prime number that precedes $ 10^n-1 $.
Example: The largest 4-digit number is $ 10^4 -1 = 10000-1 = 9999 $ so the largest prime number with $ n $ digits is the prime number preceding $ 10000 $ that is $ 9973 $.
The first 20 prime numbers in this list are: 7 (largest 1 digit prime), 97 (largest 2-digit prime), 997 (largest 3-digit prime), 9973, 99991, 999983, 9999991, 99999989, 999999937, 9999999967, 99999999977, 999999999989, 9999999999971, 99999999999973, 999999999999989, 9999999999999937, 99999999999999997, 999999999999999989, 9999999999999999961, 99999999999999999989 etc.
A prime number and the previous prime number are twins primes when their difference equals 2.
Example: 17 and 19 are called twin primes as 19-17 = 2.
dCode retains ownership of the "Previous Prime Number" source code. Except explicit open source licence (indicated Creative Commons / free), the "Previous Prime Number" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or the "Previous Prime Number" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "Previous Prime Number" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app!
Reminder : dCode is free to use.
The copy-paste of the page "Previous Prime Number" or any of its results, is allowed (even for commercial purposes) as long as you credit dCode!
Exporting results as a .csv or .txt file is free by clicking on the export icon
Cite as source (bibliography):
Previous Prime Number on dCode.fr [online website], retrieved on 2024-11-07,