Primes whose first and last number is 3: Difference between revisions

→‎{{header|XPL0}}: Revised for stretch goal.
(→‎{{header|XPL0}}: Revised for stretch goal.)
Line 343:
];
 
func Has3sStarts3(N); \Return 'true' if first andmost lastsignificant digitsdigit areis 3
int N;
[repeat N:= N/10;
until N = 0;
if rem(0) # 3 then return false;
while N do N:= N/10;
return rem(0) = 3;
];
Line 353 ⟶ 352:
int Count, N;
[Count:= 0;
N:= 3;
for N:= 0 to 4000-1 do
repeat if Has3s(N) & IsPrimeStarts3(N) then
[IntOut(0, if IsPrime(N); then
[Count:= Count+1;
if rem(Count/10) = 0 then CrLf(0) else ChOut(0, 9\tab\);if N < 4000 then
] [IntOut(0, N);
if rem(Count/10) = 0 then CrLf(0) else ChOut(0, 9\tab\);
];
];
while N do N:= N/+10;
if N = 4003 then
[CrLf(0);
IntOut(0, Count);
Text(0, " such primes found below 4000.");
];
until N >= 1_000_000;
CrLf(0);
IntOut(0, Count);
Text(0, " such primes found below 40001,000,000.
");
]</lang>
Line 372 ⟶ 381:
3863 3923 3943
33 such primes found below 4000.
2251 such primes found below 1,000,000.
</pre>
772

edits