Find prime n such that reversed n is also prime
Find prime n such that reversed n is also prime is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
- Task
Find prime n for that reversed n is also prime.
Let 0 < n < 500
Ring
<lang ring> load "stdlib.ring"
see "working..." + nl
row = 0 num = 0 limit = 500
for n = 1 to limit
strm = "" strn = string(n) for m = len(strn) to 1 step -1 strm = strm + strn[m] next strnum = number(strm) if isprime(n) and isprime(strnum) num = num + 1 row = row + 1 see "" + n + " " if row%10 = 0 see nl ok ok
next
see nl + "found " + num + " primes" + nl see "done..." + nl </lang>
- Output:
working... 2 3 5 7 11 13 17 31 37 71 73 79 97 101 107 113 131 149 151 157 167 179 181 191 199 311 313 337 347 353 359 373 383 389 found 34 primes done...