OFFSET
1,1
EXAMPLE
a(3) = 311 because the reversal of a(2) = 113 is 311 and 311 is prime.
a(4) = 11311 because the reversal of a(3) = 311 is 113, which is already in the list. The next smallest prime that starts with 113 is 11311.
MAPLE
reverse := proc (nn) local n, m; m := 0; n := nn; while (n > 0) do m := m*10 + irem(n, 10, 'n'); od; m; end:
a := proc(n, m) option remember; global currSet; local currN, i, origN, j; if n = 0 then currSet := {m}; return m; end if; currN := reverse(a(n - 1, m)); if (not (evalb(currN in currSet))) then if (isprime(currN)) then currSet := currSet union {currN}; return currN; end if; end if; origN := currN; j := 1; while (true) do origN := 10 * origN; currN := origN; i := 0; while i < (10^j) do if (isprime(currN) and (not evalb(currN in currSet))) then currSet := currSet union {currN}; return currN; end if; currN := currN + 1; i := i + 1; end do; j := j + 1; end do; return currN; end proc; (Deugau)
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Amarnath Murthy, Aug 04 2005
EXTENSIONS
More terms from Chris Deugau (deugaucj(AT)uvic.ca), Nov 04 2005
STATUS
approved