A162163 Primes p such that p-1 and p+1 can individually be written as a sum of 2 and also as a sum of 3 distinct nonzero squares.
179, 467, 739, 809, 1097, 1171, 1619, 1801, 1873, 1907, 2467, 3203, 3331, 3491, 3923, 4051, 4177, 4211, 4931, 5507, 5651, 6067, 6121, 6353, 6569, 6659, 7219, 8081, 8243, 8297, 8353, 8819, 9091, 9161, 9377, 10243, 10531, 10657, 10729, 10889, 11251, 11699
Offset: 1
Keywords
Examples
p=12113: p-1=12112 = 36^2+40^2+96^2 = 36^2+104^2; p+1=12114 = 33^2+63^2+84^2 = 33^2+105^2. p=4177: p-1=4176 = 24^2+60^2 = 24^2+36^2+48^2; p+1=4178 = 37^2+53^2 = 37^2+28^2+45^2. - _Vladimir Joseph Stephan Orlovsky_, Jun 26 2009 p=179: p-1=178 = 3^2+13^2 = 3^2+5^2+12^2; p+1=180 = 6^2+12^2=4^2+8^2+10^2. - _R. J. Mathar_, Jul 02 2009
Programs
-
Maple
isA004431 := proc(n) local x,y ; for x from 1 do if x^2 > n then RETURN(false); fi; y := n-x^2 ; if y> 0 and issqr(y ) then y := sqrt(y) ; if y <> x then RETURN(true) ; fi; fi; od: end: isA004432 := proc(n) local x,y,z ; for x from 1 do if x^2 > n then RETURN(false); fi; for y from x+ 1 do if x^2+y^2>n then break ; fi; z := n-x^2-y^2 ; if z> 0 and issqr(z ) then z := sqrt(z) ; if z > y and z > x then RETURN(true) ; fi; fi; od: od: end: for n from 1 to 2000 do p := ithprime(n) ; if isA004432(p-1) and isA004432(p+1) and isA004431(p-1) and isA004431(p+1) then printf("%d,",p) ; fi; od: # R. J. Mathar, Jul 02 2009
-
Mathematica
f[n_]:=Module[{k=1},While[(n-k^2)^(1/2)!=IntegerPart[(n-k^2)^(1/2)],k++; If[2*k^2>=n,k=0;Break[]]];k]; lst={};Do[p=Prime[n];x=p-1;y=p+1;If[f[x]> 0&&f[y]>0,a=x-(f[x])^2;b=y-(f[y])^2;If[f[a]>0&&f[b]>0,c=(x-(f[x])^2-(f[a])^2)^(1/ 2);d=(y-(f[y])^2-(f[b])^2)^(1/2);If[c!=f[x]&&c!=f[a]&&f[x]!=f[a], If[d!=f[y]&&d!=f[b]&&f[y]!=f[b],AppendTo[lst,p]]]]],{n,3,6*6!}];lst (* Vladimir Joseph Stephan Orlovsky, Jun 26 2009 *)
Formula
Extensions
Definition corrected, Mathematica duplicate removed, missing values added by R. J. Mathar, Jul 02 2009
Comments