30 lines
1.4 KiB
Plaintext
30 lines
1.4 KiB
Plaintext
;Definition
|
|
A [[wp:Factorial_prime|'''factorial prime''']] is a prime number that is one less or one more than a [[wp:Factorial|factorial]].
|
|
|
|
In other words a non-negative integer '''n''' corresponds to a factorial prime if either '''n'''! - 1 or '''n'''! + 1 is prime.
|
|
|
|
;Examples
|
|
4 corresponds to the factorial prime 4! - 1 = 23.
|
|
|
|
5 doesn't correspond to a factorial prime because neither 5! - 1 = 119 (7 x 17) nor 5! + 1 = 121 (11 x 11) are prime.
|
|
|
|
;Task
|
|
Find and show here the first 10 factorial primes. As well as the prime itself show the factorial number '''n''' to which it corresponds and whether 1 is to be added or subtracted.
|
|
|
|
As 0! (by convention) and 1! are both 1, ignore the former and start counting from 1!.
|
|
|
|
;Stretch
|
|
If your language supports arbitrary sized integers, do the same for at least the next 19 factorial primes.
|
|
|
|
As it can take a long time to demonstrate that a large number (above say 2^64) is definitely prime, you may instead use a function which shows that a number is probably prime to a reasonable degree of certainty. Most 'big integer' libraries have such a function.
|
|
|
|
If a number has more than 40 digits, do not show the full number. Show instead the first 20 and the last 20 digits and how many digits in total the number has.
|
|
|
|
;Reference
|
|
* [[oeis:A088054|OEIS:A088054 - Factorial primes]]
|
|
|
|
;Related task
|
|
* [[Sequence_of_primorial_primes|Sequence of primorial primes]]
|
|
<br><br>
|
|
|