Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
44
Task/Emirp-primes/XPL0/emirp-primes.xpl0
Normal file
44
Task/Emirp-primes/XPL0/emirp-primes.xpl0
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
func IsPrime(N); \Return 'true' if N is prime
|
||||
int N, I;
|
||||
[if N <= 2 then return N = 2;
|
||||
if (N&1) = 0 then \even >2\ return false;
|
||||
for I:= 3 to sqrt(N) do
|
||||
[if rem(N/I) = 0 then return false;
|
||||
I:= I+1;
|
||||
];
|
||||
return true;
|
||||
];
|
||||
|
||||
func Reverse(N); \Return the value of N with its digits reversed
|
||||
int N, M;
|
||||
[M:= 0;
|
||||
repeat N:= N/10;
|
||||
M:= M*10 + rem(0);
|
||||
until N = 0;
|
||||
return M;
|
||||
];
|
||||
|
||||
int N, M, Cnt;
|
||||
[N:= 13; Cnt:= 0;
|
||||
Text(0, "First 20 emirps:^m^j");
|
||||
loop [if IsPrime(N) then
|
||||
[M:= Reverse(N);
|
||||
if IsPrime(M) and M # N then
|
||||
[Cnt:= Cnt+1;
|
||||
if Cnt <= 20 then
|
||||
[IntOut(0, N); ChOut(0, ^ )];
|
||||
if Cnt = 20 then
|
||||
Text(0, "^m^jEmirps between 7700 and 8000:^m^j");
|
||||
if N >= 7700 and N <= 8000 then
|
||||
[IntOut(0, N); ChOut(0, ^ )];
|
||||
if Cnt = 10_000 then
|
||||
[Text(0, "^m^jThe 10,000 emirp: ");
|
||||
IntOut(0, N);
|
||||
CrLf(0);
|
||||
quit;
|
||||
];
|
||||
];
|
||||
];
|
||||
N:= N+2;
|
||||
];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue