dist(a,b) = sqrt(a^2+b^2); \r \r .../prog.gp dist(1,2) cmpz(a,b) = if (abs(a)>abs(b), print(a), print(b)) cmpz(a,b) = if (abs(a)>abs(b), print(a), print(b)) cmpz(a,b) = if (abs(a)>abs(b), \ print(a), \ print(b)) cmpz(a,b) = { if (abs(a)>abs(b), print(a) ,print(b)) } fibo(n)= { my(u0=0,u1=1); for(i=2,n, [u0,u1]=[u1,u0+u1]); u1; } \r fibo(100) rho(n)= { my(x=2,y=5); while(gcd(y-x,n)==1, x=(x^2+1)%n; y=(y^2+1)%n; y=(y^2+1)%n ); gcd(n,y-x); } \r rho(2^64+1) wieferich(n)= { forprime(p=2,n, if(Mod(2,p^2)^(p-1)==1, return(p))); } wieferich2(n)= { my(r); forprime(p=2,n, if(Mod(2,p^2)^(p-1)==1,r=p;break)); r; } wieferich(10000) V=vector(10,i,1/i) [1/i|i<-[1..10]] M=matrix(4,4,i,j,i*j) s3(n)= { my(m=sqrtint(n)); for (i=1,m, for (j=1,m, for (k=1,m, if (i^2+j^2+k^2==n, return([i,j,k]))))); } s3(12345) s3(n)= { my(m=sqrtint(n)); forvec(v=vector(3,i,[1,m]), if (v*v~==n, return(v))); } s3(12345) birthday(n)= { my(M = Map()); for(i=1,oo, my(x=random(n), j); if(mapisdefined(M,x,&j), return([i,j])); mapput(M,x,i)); } birthday(2^30)