is_sum_of_two_squares(N)= { local(p=ILK,nt=0,ut=0,t,v,tv=[0,0],sv=[]); local(inner1(p)= local(a,b,r0,r1,r2,kk,v,s,sv); v=polrootsmod(x^2+1,p); r1=lift(v[1]); r0=p; while(true, r2=r0%r1; kk=r2^2; if(kk
1,v=concat(v,[[0,f]])); return(v); ); v=inner2(N); if(#v>0, forvec(vx=vector(#v,i,[0,1]), t=if(vx[1]==0,(v[1][1]+v[1][2]*I),(v[1][2]+v[1][1]*I)); for(i=2,#vx, t*=if(vx[i]==0,(v[i][1]+v[i][2]*I),(v[i][2]+v[i][1]*I)); ); if (type(t)=="t_COMPLEX", sv=concat(sv,[vecsort([abs(component(t,1)),abs(component(t,2))])]); ); ); sv=vecsort(sv,1); tv+=sv[1]; nt=1; if(#sv>1, for(i=2,#sv, if(sv[i][1]!=sv[i-1][1],tv+=sv[i];nt++); ); ); ); nt } A272268(NT=30)= { local(inner(R)= for(i=1,1000, if(is_sum_of_two_squares(2*R+i)>0, return(2*R+i)) ); 0 ); local(r=1,t,sv=[1]); for(i=2,NT, t=inner(r); if(t>0,sv=concat(sv,t); r=t,break) ); sv }