Palindromic primes: Difference between revisions
m
→{{header|ALGOL 68}}: tweak
(Added S-BASIC example) |
m (→{{header|ALGOL 68}}: tweak) |
||
Line 80:
Generates the palindrmic 3 digit numbers and uses the observations that all 1 digit primes are palindromic and that for 2 digit numbers, only multiples of 11 are palindromic and hence 11 is the only two digit palindromic prime.
{{libheader|ALGOL 68-primes}}
<syntaxhighlight lang="algol68">BEGIN # find primes that are palendromic in base 10 #
INT max prime = 999;
# sieve the primes to max prime #
PR read "primes.incl.a68" PR
[]BOOL prime = PRIMESIEVE max prime;
# print the palendromic primes in the base 10 #
# all 1 digit primes are palindromic #
# so 11 is the only
# three digit numbers, the first and last digits must be odd #
▲ IF prime[ 11 ] THEN print( ( " 11" ) ) FI;
#
FOR fl BY 2 TO 9 DO
IF fl /= 5 THEN
Line 105 ⟶ 104:
OD;
print( ( newline ) )
END
{{out}}
<pre>
|