Download or view emirp.frink in plain text format
/** This is a solution for the Rosetta Code problem "emirp primes".
An emirp (prime spelled backwards) are primes that when reversed (in their
decimal representation) are a different prime.
(This rules out palindromic primes.)
https://rosettacode.org/wiki/Emirp_primes
*/
isEmirp[x] :=
{
if isPrime[x]
{
s = toString[x]
rev = reverse[s]
return s != rev and isPrime[parseInt[rev]]
}
return false
}
// Functions that return finite and infinite enumerating expressions of emirps
emirps[] := select[primes[], getFunction["isEmirp", 1]]
emirps[begin, end] := select[primes[begin, end], getFunction["isEmirp", 1]]
println["First 20: " + first[emirps[], 20]]
println["Range: " + emirps[7700, 8000]]
println["10000th: " + last[first[emirps[], 10000]]]
Download or view emirp.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20145 days, 12 hours, 34 minutes ago.