![]() |
[QUOTE=CRGreathouse;276052]GP doesn't have much in the way of I/O. I suggest
[code]extern("rm oldStatus; mv pariStatus oldStatus"); write("pariStatus", ...); extern("rm oldStatus");[/code][/QUOTE] Thanks. That would keep me from possibly losing the value. Is the first "rm oldStatus" just to "be sure" before the mv? |
[QUOTE=science_man_88;276004]yeah probably but you should still find it with mine:
[CODE](10:29)>for(x=1000010274063430,1000010274063430,b=x;for(y=1,10000000,if((sigma(b)-b) != 0,b=sigma(b)-b);if(b==x,print(x","y);break()))) 1000010274063430,2[/CODE][/QUOTE] In computer terms, yours seems to be taking an eternity to search from 1000010274060000 to 1000010274080000: [code] ? for(x=1000010274060000,1000010274080000,b=x;for(y=1,10000000,if((sigma(b)-b) != 0,b=sigma(b)-b);if(b==x,print(x","y);break()))) ^C *** sigma: user interrupt after 7mn, 32,978 ms. [/code]whereas, mine (without the extra prints) is done in a few seconds: [code] ? for(b=100001027406,100001027408,c=b*10000;for(d=c,c+10000,i=d;f=d*20;for(e=1,5,i=sigma(i)-i;if(i<d,break());if(i>f,break());if(i==d,print(d);break())))) 1000010274063430 time = 8,999 ms. [/code] |
[CODE]lucas2(t,z,p,q,x)= v=[t,z];for(y=3,x,v=concat(v,p*v[y-1]-q*v[y-2]));v=vector(x,i,v[i])[/CODE]
though I tried using it like:[CODE]for(z=-1000,1000,for(a=-1000,1000,if(lucas2(2,3,z,a,13)==[2,3,5,7,13,17,19,31,61,89,107,127,521],print(z","a))))[/CODE] and got told "bug in" I'm guessing something like the segmentation fault: please report errors. |
error testing
how can it be done in PARI because if possible it may allow me to test something , I'm currently working on related to Mersenne prime exponents. because laurv talked of code like:[CODE] sqrt(Mod(2,2^61-1)) [/CODE] well so far in testing manually I see a pattern ( gulp) to the result and I might be able to tell just by the first calculation and this kinda had to do with trying the lucas-lehmer test backwards. I think that if p is a mersenne prime exponent the result isn't and error on the second level down by adding 2 ( I am positive it's likely known though).
|
[QUOTE=science_man_88;280037]how can it be done in PARI because if possible it may allow me to test something , I'm currently working on related to Mersenne prime exponents. because laurv talked of code like:[CODE] sqrt(Mod(2,2^61-1)) [/CODE] well so far in testing manually I see a pattern ( gulp) to the result and I might be able to tell just by the first calculation and this kinda had to do with trying the lucas-lehmer test backwards. I think that if p is a mersenne prime exponent the result isn't and error on the second level down by adding 2 ( I am positive it's likely known though).[/QUOTE]
doh I found it I think lol trap() still not sure how to use it. |
The general format is
trap(, code, what to do if the code fails) as in [code]trap(,1/0,"don't divide by 0")[/code] Technically you can put the error type before the first comma to catch only certain types of errors, but usually you don't want to do this. |
[QUOTE=CRGreathouse;280126]The general format is
trap(, code, what to do if the code fails) as in [code]trap(,1/0,"don't divide by 0")[/code] Technically you can put the error type before the first comma to catch only certain types of errors, but usually you don't want to do this.[/QUOTE] thanks I already proved myself wrong without it but I still want to see if it even semi fits: [CODE](17:34)>b=2;forprime(p=2281,2281,for(y=1,p-1,b=sqrt(Mod(b,1<<p-1));trap(,break(),);if(y==p-1,print(p)));b=2) *** sqrt: user interrupt after 13,750 ms. *** break: bug in PARI/GP (Segmentation Fault), please report *** Break loop (type 'break' or Control-d to go back to GP)[/CODE] |
[QUOTE=science_man_88;280132]thanks I already proved myself wrong without it but I still want to see if it even semi fits:
[CODE](17:34)>b=2;forprime(p=2281,2281,for(y=1,p-1,b=sqrt(Mod(b,1<<p-1));trap(,break(),);if(y==p-1,print(p)));b=2) *** sqrt: user interrupt after 13,750 ms. *** break: bug in PARI/GP (Segmentation Fault), please report *** Break loop (type 'break' or Control-d to go back to GP)[/CODE][/QUOTE] [CODE](17:37)>b=2;forprime(p=29,29,for(y=1,p-1,b=sqrt(Mod(b,1<<p-1));if(y==p-1,print(p)));b=2) *** sqrt: non quadratic residue in gsqrt *** break: bug in PARI/GP (Segmentation Fault), please report *** Break loop (type 'break' or Control-d to go back to GP)[/CODE] |
hopefully I don't have to reinstall ( though likely) I've had segmentation faults too much ( stupidly ignored a little) and even my timer seems wacky at times.
|
You're using trap wrong. You're writing
code; trap(, stuff, ) when I told you to write trap(, code, stuff) What you did will still cause the error. [QUOTE=science_man_88;280136]hopefully I don't have to reinstall[/QUOTE] No, you don't need to do that. |
I don't know what are you trying to do (semantically), but (syntactically) you should write this:
[CODE] (10:06:27) gp > b=2;forprime(p=2,2281,for(y=1,p-1,trap(,print("break here, p="p", y="y);break,b=sqrt(Mod(b,1<<p-1)));if(y==p-1,print(p)));b=2) break here, p=2, y=1 break here, p=3, y=2 break here, p=5, y=3 7 break here, p=11, y=6 break here, p=13, y=7 break here, p=17, y=5 break here, p=19, y=10 23 break here, p=29, y=15 31 break here, p=37, y=19 break here, p=41, y=11 break here, p=43, y=8 47 break here, p=53, y=27 [/CODE] |
| All times are UTC. The time now is 22:48. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.