Find prime n such that reversed n is also prime: Difference between revisions

(→‎OCaml: add)
(→‎bc: add)
Line 262:
311 313 337 347 353
359 373 383 389</pre>
 
=={{header|bc}}==
<syntaxhighlight lang="bc">define t(n) {
auto i, p
if (n == 2) return(1)
for (i = 0; n % (p = a[i]) != 0; ++i) if (p * p > n) return(1)
return(0)
}
 
define r(n) {
auto m
for (m = 0; n > 9; n /= 10) m = (n % 10 + m) * 10
return(m + n)
}
 
for (n = 2; n != 500; ++n) if (t(n) != 0) a[o++] = n
 
for (i = 0; i != o; ++i) if (t(r(n = a[i])) != 0) n</syntaxhighlight>
 
=={{header|BCPL}}==
559

edits