[go: up one dir, main page]

login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A215932
Happy reversible primes.
0
7, 13, 31, 79, 97, 167, 313, 383, 709, 739, 761, 907, 937, 1009, 1033, 1151, 1487, 1511, 1733, 1847, 1933, 3019, 3067, 3083, 3109, 3301, 3319, 3371, 3391, 3463, 3643, 3803, 7457, 7481, 7547, 7589, 7603, 7841, 9001, 9013, 9103, 9133, 9857, 10009, 10039, 10067
OFFSET
1,1
COMMENTS
Happy numbers that are prime and if the digits are reversed they remain prime (and of course happy, since addition is commutative).
Intersection of A007500 and A007770. - N. J. A. Sloane, Mar 16 2013
This is to A031161 (palindromic lucky numbers) as prime happy numbers are to lucky numbers (A000959). - Jonathan Vos Post, Mar 16 2013
MATHEMATICA
revpQ[n_] := PrimeQ[n] && PrimeQ[FromDigits@Reverse@IntegerDigits@n]; happyQ[n_] := Block[{w = n}, While[w > 6, w = Total[ IntegerDigits[w]^2]]; w == 1]; Select[Range[10^4], revpQ[#] && happyQ[#] &] (* Giovanni Resta, Mar 16 2013 *)
PROG
(C)
int main()
{long unsigned int n, i, si, a[]={4, 16, 37, 58, 89, 145, 42, 20}, t, x, c1=0, sod(long unsigned int), rev(long unsigned int), prim(long unsigned int);
for(n=2; n<=12000; n++) {t=n; si=0; while(si!=1){for(i=0; i<=7; i++){if(t==a[i]){si=1; break; }}
if(t==1){si=1; if(prim(n)==0){x=rev(n); if(prim(x)==0){printf(", %lu", n); c1=c1+1; }}}t=sod(t); }}}
long unsigned int sod(long unsigned int m){long unsigned int d=0, r; while(m>0){r=m%10; d=d+r*r; m=m/10; } return(d); }
long unsigned int rev(long unsigned int p){long unsigned int d=0, r; while(p>0){r=p%10; d=d*10+r; p=p/10; }return(d); }
long unsigned int prim(long unsigned int n){long unsigned int i, d=0; for(i=2; i<=n/2; i++){if(n%i==0){d=1; break; }}return(d); }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Jayanta Basu, Mar 16 2013
STATUS
approved