A367798
Primes p such that p^2 is the sum of a prime and its reverse.
Original entry on oeis.org
2, 11, 307, 35419, 347651, 3091643, 3417569, 30001253, 34158919, 35515619, 305524927, 312123463, 313513517, 327371987, 337660679, 348898811, 352023571, 3013005397, 3051026827, 3147298717, 3149171717, 3171167353, 3175236553, 3226951193, 3248169343, 3306563683, 3350101739, 3366748421, 3403341569
Offset: 1
a(1) = 2 is a term because 2^2 = 4 = 2 + 2 with 2 prime.
a(2) = 11 is a term because 11^2 = 121 = 29 + 92 with 11 and 29 prime.
a(3) = 307 is a term because 307^2 = 94249 = 20147 + 74102 with 307 and 20147 prime.
a(4) = 35419 is a term because 35419^2 = 1254505561 = 261104399 + 993401162 with 35419 and 261104399 prime.
a(5) = 347651 is a term because 347651^2 = 120861217801 = 20870609999 + 99990607802 with 347651 and 20870609999 prime.
a(6) = 3091643 is a term because 3091643^2 = 9558256439449 = 2059108419947 + 7499148019502 with 3091643 and 2059108419947 prime.
a(7) = 3417569 is a term because 3417569^2 = 11679777869761 = 2080783998959 + 9598993870802 with 3417569 and 2080783998959 prime.
a(8) = 30001253 is a term because 30001253^2 = 900075181570009 = 200000140570007 + 700075041000002 with 30001253 and 200000140570007 prime.
a(9) = 34158919 is a term because 34158919^2 = 1166831747248561 = 206841324099959 + 959990423148602 with 34158919 and 206841324099959 prime.
a(10) = 35515619 is a term because 35515619^2 = 1261359192953161 = 261359249999999 + 999999942953162 with 35515619 and 261359249999999 prime.
-
f:= proc(n) local y,c,d,dp,i,delta,m;
y:= convert(n^2,base,10);
d:= nops(y);
if d::even then
if y[-1] <> 1 then return false fi;
dp:= d-1;
y:= y[1..-2];
c[dp]:= 1;
else
dp:= d;
c[dp]:= 0;
fi;
c[0]:= 0;
for i from 1 to floor(dp/2) do
delta:= y[i] - y[dp+1-i] - c[i-1] - 10*c[dp+1-i];
if delta = 0 then c[dp-i]:= 0; c[i]:= 0;
elif delta = -1 then c[dp-i]:= 1; c[i]:= 0;
elif delta = -10 then c[dp-i]:= 0 ; c[i]:= 1;
elif delta = -11 then c[dp-i]:= 1; c[i]:= 1;
else return false
fi;
if y[i] + 10*c[i] - c[i-1] < 0 or (i=1 and y[i]+10*c[i]-c[i-1]=1) then return false fi;
od;
m:= (dp+1)/2;
delta:= y[m] + 10*c[m] - c[m-1];
if not member(delta, [seq(i,i=0..18,2)]) then return false fi;
[seq(y[i]+ 10*c[i]-c[i-1],i=1..m)]
end proc:
g:= proc(L) local T,d,t,p, x, i; uses combinat;
d:= nops(L);
T:= cartprod([select(t -> t[1]::odd, [seq([L[1]-x,x],x=max(1,L[1]-9)..min(L[1],9))]),
seq([seq([L[i]-x,x],x=max(0,L[i]-9)..min(9, L[i]))],i=2..d-1)]);
while not T[finished] do
t:= T[nextvalue]();
p:= add(t[i][1]*10^(i-1),i=1..d-1) + L[-1]/2 * 10^(d-1) +
add(t[i][2]*10^(2*d-i-1),i=1..d-1);
if isprime(p) then return p fi;
od;
-1
end proc:
p:= 11: R:= 2, 11:
while p < 10^8 do
p:= nextprime(p);
d:= 1+ilog10(p^2);
if d::even and p^2 >= 2*10^(d-1) then p:= nextprime(floor(10^(d/2))); fi;
v:= f(p);
if v = false then next fi;
q:= g(v);
if q = -1 then next fi;
R:= R, p;
od:
R;
A367871
a(n) is the least prime q such that A367798(n)^2 is the sum of q and its reversal.
Original entry on oeis.org
2, 29, 20147, 261104399, 20870609999, 2059108419947, 2080783998959, 200000140570007, 206841324099959, 261359249999999, 20401390509044927, 20421109564999967, 20000105691609287, 27180442947919997, 20105039549690939, 22040085159209699, 24000605788991999, 2008220921060899607, 2008804724799599927
Offset: 1
a(4) = 261104399 because A367798(3) = 35419 and 35419^2 = 1254505561 = 261104399 + 993401162 and 261104399 is the first prime that works.
-
f:= proc(n) local y, c, d, dp, i, delta, m;
y:= convert(n^2, base, 10);
d:= nops(y);
if d::even then
if y[-1] <> 1 then return false fi;
dp:= d-1;
y:= y[1..-2];
c[dp]:= 1;
else
dp:= d;
c[dp]:= 0;
fi;
c[0]:= 0;
for i from 1 to floor(dp/2) do
delta:= y[i] - y[dp+1-i] - c[i-1] - 10*c[dp+1-i];
if delta = 0 then c[dp-i]:= 0; c[i]:= 0;
elif delta = -1 then c[dp-i]:= 1; c[i]:= 0;
elif delta = -10 then c[dp-i]:= 0 ; c[i]:= 1;
elif delta = -11 then c[dp-i]:= 1; c[i]:= 1;
else return false
fi;
if y[i] + 10*c[i] - c[i-1] < 0 or (i=1 and y[i]+10*c[i]-c[i-1]=1) then return false fi;
od;
m:= (dp+1)/2;
delta:= y[m] + 10*c[m] - c[m-1];
if not member(delta, [seq(i, i=0..18, 2)]) then return false fi;
[seq(y[i]+ 10*c[i]-c[i-1], i=1..m)]
end proc:
g:= proc(L) local T, d, t, p, x, i; uses combinat;
d:= nops(L);
T:= cartprod([select(t -> t[1]::odd, [seq([L[1]-x, x], x=max(1, L[1]-9)..min(L[1], 9))]),
seq([seq([L[i]-x, x], x=max(0, L[i]-9)..min(9, L[i]))], i=2..d-1)]);
while not T[finished] do
t:= T[nextvalue]();
p:= add(t[i][1]*10^(i-1), i=1..d-1) + L[-1]/2 * 10^(d-1) +
add(t[i][2]*10^(2*d-i-1), i=1..d-1);
if isprime(p) then return p fi;
od;
-1
end proc:
p:= 11: Q:=29:
while p < 10^8 do
p:= nextprime(p);
d:= 1+ilog10(p^2);
if d::even and p^2 >= 2*10^(d-1) then p:= nextprime(floor(10^(d/2))); fi;
v:= f(p);
if v = false then next fi;
q:= g(v);
if q = -1 then next fi;
Q:= Q, q;
od:
Q;
A367900
a(n) is the greatest prime q such that A367798(n)^2 is the sum of q and its reversal.
Original entry on oeis.org
2, 83, 81131, 894500063, 88990607813, 8499228209501, 8597793891803, 800072140300001, 859981720058603, 899969843983163, 82943190509220401, 86999838571212401, 88290616680100001, 89991996902408171, 83909667566050103, 89690298128004023, 89919974791600043, 8069990701280128001, 8299959944574088001
Offset: 1
a(4) = 894500063 because A367798(3) = 35419 and 35419^2 = 1254505561 = 894500063 + 360005498 and 894500063 is the greatest prime that works.
-
f:= proc(n) local y, c, d, dp, i, delta, m;
y:= convert(n^2, base, 10);
d:= nops(y);
if d::even then
if y[-1] <> 1 then return false fi;
dp:= d-1;
y:= y[1..-2];
c[dp]:= 1;
else
dp:= d;
c[dp]:= 0;
fi;
c[0]:= 0;
for i from 1 to floor(dp/2) do
delta:= y[i] - y[dp+1-i] - c[i-1] - 10*c[dp+1-i];
if delta = 0 then c[dp-i]:= 0; c[i]:= 0;
elif delta = -1 then c[dp-i]:= 1; c[i]:= 0;
elif delta = -10 then c[dp-i]:= 0 ; c[i]:= 1;
elif delta = -11 then c[dp-i]:= 1; c[i]:= 1;
else return false
fi;
if y[i] + 10*c[i] - c[i-1] < 0 or (i=1 and y[i]+10*c[i]-c[i-1]=1) then return false fi;
od;
m:= (dp+1)/2;
delta:= y[m] + 10*c[m] - c[m-1];
if not member(delta, [seq(i, i=0..18, 2)]) then return false fi;
[seq(y[i]+ 10*c[i]-c[i-1], i=1..m)]
end proc:
g:= proc(L) local T, d, t, p, x, i; uses combinat;
d:= nops(L);
T:= cartprod([select(t -> t[1]::odd, [seq([L[1]-x, x], x=min(L[1], 9)..max(1, L[1]-9),-1)]),
seq([seq([L[i]-x, x], x=min(9, L[i])..max(0, L[i]-9),-1)], i=2..d-1)]);
while not T[finished] do
t:= T[nextvalue]();
p:= add(t[i][1]*10^(i-1), i=1..d-1) + L[-1]/2 * 10^(d-1) +
add(t[i][2]*10^(2*d-i-1), i=1..d-1);
if isprime(p) then return p fi;
od;
-1
end proc:
p:= 2, 11: Q:= 83:
while p < 10^10 do
p:= nextprime(p);
d:= 1+ilog10(p^2);
if d::even and p^2 >= 2*10^(d-1) then p:= nextprime(floor(10^(d/2))); fi;
v:= f(p);
if v = false then next fi;
q:= g(v);
if q = -1 then next fi;
Q:= Q, q;
od:
Q;
Showing 1-3 of 3 results.
Comments