Anonymous user
Wieferich primes: Difference between revisions
m
→{{header|REXX}}: added whitespace and comments, added a "filter" comment.
m (→{{header|REXX}}: added whitespace and comments, added a "filter" comment.) |
|||
Line 588:
found= 0 /*initialize number of Wieferich primes*/
do j=1 to #; p= @.j /*search for Wieferich primes in range.*/
if (2**(p-1)-1)//p**2\==0 then iterate /*P**2 not evenly divide 2**(P-1) - 1?*/ /* ◄■■■■■■■ the filter.*/
found= found + 1 /*bump the counter of Wieferich primes.*/
say center(found, 7)'│' center(commas(p), w) /*display the Wieferich prime.*/
Line 599:
commas: parse arg ?; do jc=length(?)-3 to 1 by -3; ?=insert(',', ?, jc); end; return ?
/*──────────────────────────────────────────────────────────────────────────────────────*/
genP: @.1=2;
!.=0; !.2=1; !.3=1; !.5=1; !.7=1; !.11=1 /* " " " " (semaphores).*/
#= 5; sq.#= @.# **
do j=@.#+2 by 2 to n-1; parse var j '' -1 _ /*
if _==5 then iterate
if j//3==0 then iterate; if j//7==0 then iterate
do k=5 while sq.k<=j /* [↓] divide by the known odd primes.*/
if j//@.k==0 then iterate j /*Is J ÷ a P? Then not prime. ___ */
|