Anonymous user
Carmichael 3 strong pseudoprimes: Difference between revisions
Carmichael 3 strong pseudoprimes (view source)
Revision as of 06:15, 11 December 2012
, 11 years ago→{{header|REXX}}: made some cometic changes, removed calculation with even prime (Carmicahael numbers can't be even). -- ~~~~
m (→{{header|Python}}: Cap.) |
m (→{{header|REXX}}: made some cometic changes, removed calculation with even prime (Carmicahael numbers can't be even). -- ~~~~) |
||
Line 283:
<lang rexx>/*REXX program calculates Carmichael 3-strong pseudoprimes. */
numeric digits 30 /*in case user wants bigger nums.*/
parse arg
if 1=='f1'x then times='af'x /*if EBCDIC machine, use a bullet*/
else times='f9'x /* " ASCII " " " " */
carms=0 /*number of Carmichael #s so far.*/
!.=0 /*a method of prime memoization. */
do p=3 to N by 2; if \isPrime(p) then iterate /*Not prime? Skip.*/
pm=p-1;
q=1+pm*g%d; if \isPrime(q) | q==p then iterate
say '──────── a Carmichael number: ' p times q times r
carms=carms+1 /*bump the Carmichael # counter. */
say
say; say carms ' Carmichael numbers found.'
exit /*stick a fork in it, we're done.*/
Line 312 ⟶ 307:
if wordpos(x,'2 3 5 7')\==0 then do; !.x=1; return 1; end
if x<11 then return 0; if x//2==0 then return 0; if x//3==0 then return 0
▲ if x//(i+2)==0 then return 0
end /*i*/
!.x=1; return 1</lang>
'''output''' when using the default input
<pre style="height:30ex;overflow:scroll">
|