login
If n is prime a(n) = n else a(n) = nextprime(reverse(n)), where "next prime" is the smallest prime >= n, see A007918.
1

%I #20 May 12 2018 10:44:31

%S 2,2,3,5,5,7,7,11,11,2,11,23,13,41,53,61,17,83,19,2,13,23,23,43,53,67,

%T 73,83,29,3,31,23,37,43,53,67,37,83,97,5,41,29,43,47,59,67,47,89,97,5,

%U 17,29,53,47,59,67,79,89,59,7,61,29,37,47,59,67,67,89,97,7,71,29,73,47,59,67,79,89,79,11,19,29

%N If n is prime a(n) = n else a(n) = nextprime(reverse(n)), where "next prime" is the smallest prime >= n, see A007918.

%H Maghraoui Abdelkader, <a href="/A262463/b262463.txt">Table of n, a(n) for n = 1..200</a>

%F a(n)=n if n is prime;

%F else b=reverse(n);

%F if b is prime a(n)=b else a(n)=nextprime(b);

%F (using "next prime" function as "smallest prime >= n"; see A007918. )

%e For n=7 a(7)=7.

%e For n=12, reverse(12)=21; a(12)=nextprime(21)=23.

%t Table[Which[PrimeQ[n],n,PrimeQ[IntegerReverse[n]],IntegerReverse[n], True, NextPrime[ IntegerReverse[ n]]],{n,100}] (* _Harvey P. Dale_, May 12 2018 *)

%o (PARI) rev(n)={d=digits(n); p=""; for(i=1, #d, p=concat(Str(d[i]), p)); return(eval(p))}

%o i=0; t=vector(200);

%o findn(n)={if(isprime(n),t[i++]=n, a=rev(n); b=nextprime(a); t[i++]=b); }

%o for(n=1,200,findn(n)); t

%Y Cf. A000040, A077018.

%K nonn,base

%O 1,1

%A _Maghraoui Abdelkader_, Sep 23 2015