RosettaCodeData/Task/Descending-primes/XPL0/descending-primes.xpl0
2023-07-01 13:44:08 -04:00

25 lines
523 B
Text

include xpllib; \provides IsPrime and Sort
int I, N, Mask, Digit, A(512), Cnt;
[for I:= 0 to 511 do
[N:= 0; Mask:= I; Digit:= 9;
while Mask do
[if Mask&1 then
N:= N*10 + Digit;
Mask:= Mask>>1;
Digit:= Digit-1;
];
A(I):= N;
];
Sort(A, 512);
Cnt:= 0;
Format(9, 0);
for I:= 1 to 511 do \skip empty set
[N:= A(I);
if IsPrime(N) then
[RlOut(0, float(N));
Cnt:= Cnt+1;
if rem(Cnt/10) = 0 then CrLf(0);
];
];
]