Palindromic primes: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added comments.) |
(Added XPL0 example.) |
||
Line 678: | Line 678: | ||
93 such primes found, 113 in all. |
93 such primes found, 113 in all. |
||
</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 Reverse(N); |
|||
int N, M; |
|||
[M:= 0; |
|||
repeat N:= N/10; |
|||
M:= M*10 + rem(0); |
|||
until N=0; |
|||
return M; |
|||
]; |
|||
int Count, N; |
|||
[Count:= 0; |
|||
for N:= 1 to 1000-1 do |
|||
if N=Reverse(N) & IsPrime(N) then |
|||
[IntOut(0, N); |
|||
Count:= Count+1; |
|||
if rem(Count/10) = 0 then CrLf(0) else ChOut(0, 9\tab\); |
|||
]; |
|||
]</lang> |
|||
{{out}} |
|||
<pre> |
|||
2 3 5 7 11 101 131 151 181 191 |
|||
313 353 373 383 727 757 787 797 919 929 |
|||
</pre> |
</pre> |