Paul Underwood on Thu, 20 Apr 2023 12:01:06 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Factoring Carmichael Numbers
|
- To: pari-dev@pari.math.u-bordeaux.fr
- Subject: Re: Factoring Carmichael Numbers
- From: Paul Underwood <paulunderwood@mindless.com>
- Date: Thu, 20 Apr 2023 11:59:43 +0200
- Delivery-date: Thu, 20 Apr 2023 12:01:06 +0200
- Sensitivity: Normal
- Ui-outboundreport: notjunk:1;M01:P0:mv4l0NSKRxI=;lj1So418nSglbYPHURwUZRcQk3a 3aiKMThDU1Z5z4I5UHWarF862E5uavFFt97VI729iPkgkJAFM2RwTdiTrP4IbHLeKeVXpODT5 6O3CM9EAMyInzSa0QW6OBeEne85v1RXP31pZczwazMlWQv56JnzUu0ICmmPqsQnfll0P9UZTM L6z0Ke+ZYslzBDaq3qVnTxlfNsYIwqdP8L12dp8P7Vct25BZvX6h+5lPF/r7YvMP5MSfKCL4p GEfUN1rP8Dh7IYcoPTsSPBFc40vO101CODVl047+HJ74jyZkZ7UUw831l6c0BbghKzW6O5dfB lIa8jTZY51L6nogC+hvKyGP4fW0MKbcizgg7nH46gctuWjshwPLKo9Fs+DMxlaIRcba2e1xsl Bf/9Wqb0xP7fl0/ntIbG3WVpLyveBVXjNmTDcMDVQ5cJHscXvXuE/Vxph3F5SNTJ7NpAKgDvG BUegyQabDNiwJFjonShTqU3Z5OwNOx3jRSvQ3SuRp1wnqStdTE0qwFX0JdVGT83cWj2FYal7n XDMK5lP+Y4WKaiaMiaJ72wJiaots9M3ja9AXhrBhjqjXX09Do5Ef31ZvbkyA5zu/2f1TBY6bP l7aS294ER0ndARi/34M/xg67Bc73n74rWIoacUW6sTM2PFAV9Ste5AkJC5DduRwBdL5yX7wU6 IswmmJFq6F/2VaGcHowDme8Jtk+HeAi6m+neUc+pG0cW33n7rSFyqn225cgnLkcvn+pG7BaMg fhEi3y7e6U+GTgjBF4Lv5VblfWWuAjjxtmgloKHdMj+hhsS9VzcpYWRtvj1MberbCLnzJQ/P/ btNTDDZNr9Bi7cshlPSO+aTw==
Hi Bill,
thank you for the explanation about factor().
I have majorly increased the speed of my code, partly by incorporating factor() into it, but mostly by switching from expensive 2 selfridges Lucas sequences to 1 selfridge "Miller-Rabin" type calculations. The code now computes the maximum g.c.d of N with the "simple" algebraic factors of a^(n-1)-1.
{global(nm1);} \\obsolete
{Cf(n)=nm1=n-1;vecsort(CF(n));} // main function
{CF(N)=my(v,k,a,i,g,mx,V1,V2);v=valuation(nm1,2);while(1,
k=Mod(random(1000000)+2,N);a=k^(nm1/2^v);
mx=lift(gcd(a-1,N));for(i=0,v-1,g=lift(gcd(a+1,N));if(g>mx,mx=g);a*=a);
if(mx>1,if(ispseudoprime(mx),V1=[mx],if(#mx<3,V1=factor(mx)~[1,],V1=CF(mx)));
g=N/mx;if(ispseudoprime(g),V2=[g],if(#g<3,V2=factor(g)~[1,],V2=CF(g)));
return(concat(V1,V2))));}
> For 662.txt, it would finish in less than 5 seconds.
> For 5616.txt, it would take 7h, 6min, 216 ms.
Now:
662.txt 5 seconds
5616.txt 24mins 3515 ms.
Best
Paul Underwood