Message Boards Message Boards


Fast algorithm to obtain prime numbers and some pseudoprimes

Posted 7 months ago
1 Reply
0 Total Likes

Hello All:

I have obtained a fast algorithm to obtain prime numbers and some pseudoprimes:

G[n_, i_] := PowerMod[i, n+ i, n + i]

n = 10^100

While[n < 10^100 + 100000, i = 2; While[Abs[G[n, i] - i] > 0, i++]; 
  Print[n + i, " ", PrimeQ[n + i]]; n = n + i]

Can you analyze it?


Sebastián Martin Ruiz

Posted 6 months ago

Hello Sebasti√°n Martin Ruiz-san

This is a very interesting program.

It's great that it's a short program, fast and easy to handle large numbers.

I still don't understand the structure of this program. There are also functions that I haven't used yet. I will study using this as a teaching material.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract