hermann on Sat, 19 Aug 2023 23:12:06 +0200


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

Re: New gp features


On 2023-08-19 22:37, Bill Allombert wrote:
...
hermann@7600x:~$ gp -q
? foreach2(a,c) = foreach(a,b,c(b))
(a,c)->foreach(a,b,c(b))
? foreach2(a,t->printf("%d ",t[1]))
  ***   at top-level: foreach2(a,t->printf("%d ",t[1]))
  ***                 ^---------------------------------

You forgot to define "a" !

Cheers,
Bill.

You are absolutely right, your foreach2() like a charm:

hermann@7600x:~/RSA_numbers_factored/pari$ gp -q
? \r RSA_numbers_factored
validate(rsa): ✓
? foreach2(a,c) = foreach(a,b,c(b))
(a,c)->foreach(a,b,c(b))
? foreach2(rsa,t->printf("%d ",t[1]))
59 79 100 110 120 129 130 140 150 155 160 170 576 180 190 640 200 210 704 220 230 232 768 240 250 260 270 896 280 290 300 309 1024 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 1536 470 480 490 500 617 2048
?

Nice, RSA numbers are of the form [l,n[,p,q[,pm1,qm1]]].
Where l is the binary or decimal digit length of n:

? assert(b) = { if(!(b), error("assertion failed")); }
? foreach2(rsa,t->assert(t[1]==#digits(t[2]) || t[1]==#binary(t[2])))
?

Regards,

Hermann.