hermann on Sat, 14 Feb 2026 17:52:52 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Problem with recursive function return value


On 2026-02-14 16:30, Bill Allombert wrote:
On Sat, Feb 14, 2026 at 03:54:14PM +0100, hermann@stamm-wilbrandt.de wrote:
? A=[1,2;2,3;2,11;3,31];
? mo(v)=Mod(v[1],v[2]);
? ch(M)=print(M);if(#M==1,mo(A[,1]),chinese(mo(A[,1]),ch(M[,2..#M])));

Did you mix A and M ?

Yes, sorry for that simple mistake. I eliminated redundancy now by aborting for empty matrix.


The code is for playing with Brillhardt, Lehmer and Selfridge 1975 paper theorem 1
https://t5k.org/prove/prove3_1.html

in the context of of relaxed Euclid numbers:
https://oeis.org/A391020


Just learned about "Col()" and Matrix creation with comprehension, nice.

$ gp -q
? version
[2, 17, 2]
? qnr(n)=forprime(p=2,n-1,if(kronecker(p,n)==-1,return(p)));1; \\ 1 for n==2
? mo(v)=Mod(v[1],v[2]);
? ch(M)=!#M&&return(Mod(0,1));chinese(mo(M[,1]),ch(M[,2..#M]));
? N=2047;
? A=Mat([Col([qnr(p),p])|p<-factor(N-1)[,1]])

[1 2  2  3]

[2 3 11 31]

? a=lift(ch(A))
1553
?

I determined these three numbers in intersection of Fermat pseudoprimes A001567 and Euler-Jacobi pseudoprimes A047713 with no quadratic prime factors to be "similar" to Euclidean numbers:

2047     =1+[2, 1; 3, 1; 11, 1; 31, 1]
19404139 =1+[2, 1; 3, 1; 13, 1; 47, 1; 67, 1; 79, 1]
158496911=1+[2, 1; 5, 1; 11, 1; 13, 1; 23, 1; 61, 1; 79, 1]

Unfortunately none of those is a PRP to the computed base a (for first condition of theorem 1), only to base 2:

? Mod(a,N)^(N-1)
Mod(622, 2047)
? Mod(2,N)^(N-1)
Mod(1, 2047)
?

Its not that easy to find a composite number of form 1+2*\prod_{i in I} p_i that is a PRP to base a computed as above (a is quadratic non-residue to all prime divisors of N-1) ...


Regards,

Hermann.