1
$\begingroup$

Begin with P={2}; then form,m, the sum of 1 with the product overall elements of P. Place the smallest prime factor of m into P and repeat.

Suppose p = {p1,p2,...,pr}, then m = 1+ p1p2p3...pr.

Example:

2 is prime and 2+1 = 3 is prime;

2 * 3 +1 = 7 is prime;

2 * 3 * 7 +1 = 43 is prime;

2 * 3 * 7 * 43 +1 = 1807 = 13 * 139, then 13 is the prime;

Thus the first 5 prime number found by the classical proof is {2,3,7,43,13}.

So how to use this proof to find the first 20 prime in Mathematica? Thank you.

$\endgroup$

1 Answer 1

2
$\begingroup$
Clear["Global`*"]

n = 20;

(p = Nest[Join[#, {FactorInteger[1 + Times @@ #][[1, 1]]}] &,
    {2}, n - 1]) // AbsoluteTiming

(* {57.663, {2, 3, 7, 43, 13, 53, 5, 6221671, 38709183810571, 139, 2801, 
  11, 17, 5471, 52662739, 23003, 30693651606209, 37, 1741, 1313797957}} *)

Length[p]

(* 20 *)

And @@ (PrimeQ /@ p)

(* True *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.