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

Added XPL0 example.
(Created page with "{{Draft task}} ;Task:Find primes '''n''' whose first and last number is '''3''', where '''n < 4,000''' <br><br> =={{header|Ring}}== <lang ring> load "stdlib.ring" see "work...")
 
(Added XPL0 example.)
Line 39:
Found 33 numbers
done...
</pre>
 
=={{header|XPL0}}==
<lang XPL0>func IsPrime(N); \Return 'true' if N is a prime number
int N, I;
[if N <= 1 then return false;
for I:= 2 to sqrt(N) do
if rem(N/I) = 0 then return false;
return true;
];
 
func Has3s(N); \Return 'true' if first and last digits are 3
int N;
[N:= N/10;
if rem(0) # 3 then return false;
while N do N:= N/10;
return rem(0) = 3;
];
 
int Count, N;
[Count:= 0;
for N:= 0 to 4000-1 do
if Has3s(N) & IsPrime(N) then
[IntOut(0, N);
Count:= Count+1;
if rem(Count/10) = 0 then CrLf(0) else ChOut(0, 9\tab\);
];
CrLf(0);
IntOut(0, Count);
Text(0, " such primes found below 4000.
");
]</lang>
 
{{out}}
<pre>
3 313 353 373 383 3023 3083 3163 3203 3253
3313 3323 3343 3373 3413 3433 3463 3533 3583 3593
3613 3623 3643 3673 3733 3793 3803 3823 3833 3853
3863 3923 3943
33 such primes found below 4000.
</pre>
772

edits