mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   PARI/GP (https://www.mersenneforum.org/forumdisplay.php?f=155)
-   -   PARI's commands (https://www.mersenneforum.org/showthread.php?t=13636)

CRGreathouse 2011-07-01 04:05

I can't say why you got that without seeing your code, but my display code is slightly wrong (worked in my original version, failed when I translated it into a simpler version for you).

Try
[code]n=0;
vector(numberOfPrimes,unused,
n++;
while(b[n]==0,n++);
n
)[/code]

science_man_88 2011-07-01 11:09

[QUOTE=CRGreathouse;265121]I can't say why you got that without seeing your code, but my display code is slightly wrong (worked in my original version, failed when I translated it into a simpler version for you).

Try
[code]n=0;
vector(numberOfPrimes,unused,
n++;
while(b[n]==0,n++);
n
)[/code][/QUOTE]

still gives the error I got.

science_man_88 2011-07-06 22:56

TF code
 
based on what i see at:

[url]http://www.mersenne.org/various/math.php[/url]

I made a TF code a MTF code and a loop involving MTF to check prime exponents.

[CODE](17:58)>?TF
TF(x,y,B)=a=binary(x);b=0;for(c=1,#a,if(a[c]==1,if(c==1,b=((a[c]^2)*B)%y,b=((b^2)*B)%y),b=(b^2)%y));return(b);if(b==1,return(1),return(0))
(19:56)>?MTF
MTF(p,d,e)=for(k=d,e,if((2*k*p+1)%8==7&&TF(p,2*k*p+1,2)==1,return(2*k*p+1);break()))[/CODE]

I changed it once I made it after showing myself it could work with other bases ( I gave examples in the thread named that) as well as for higher exponents using lower binary values but a modified values to multiply all but that last 1 by ( which lets you test exponents k*p+1 , which I've been pointed to ( and kinda realized) that most of the supposed use of the altered version ( one situation I haven't coded yet) is useless due to the knowledge of 3 mod 4 and isprime(2p+1)) . the main problem with the alteration is finding a point at which the extra bits in the multiply , square and mod operations, are worth it for less of each.

3.14159 2011-08-03 03:47

Wow. It'll take quite a bit of time to catch up to everything... How long was I out?

And I see familiar faces here. What have you all been working on?

CRGreathouse 2011-08-03 14:43

[QUOTE=3.14159;268161]Wow. It'll take quite a bit of time to catch up to everything... How long was I out?[/QUOTE]

Six hundred years. I didn't want to be the one to tell you this, but everyone you knew is now dead.

Wait, wrong cue card.

[QUOTE=3.14159;268161]And I see familiar faces here. What have you all been working on?[/QUOTE]

In the PARI world I'm trying to get new features added:
[url]http://pari.math.u-bordeaux.fr/archives/pari-dev-1107/msg00006.html[/url]

Some of these I wrote already, some are just ideas.

Outside of that, I'm going to the Rabin conference/party/thing on the 29th-30th. I've been fairly busy with the OEIS, too -- submissions increase faster than the editorial board. :smile:

3.14159 2011-08-03 15:07

Aww, man.. I saw that PARI can't be updated for Windows anymore..

Or, rather, "don't have a reliable Windows machine to make them anymore"

[quote]Warning: I no longer have a Windows machine on which to build these reliably. The old packages remain and may or may not cooperate nicely with your own Windows machine (they don't with mines). For the time being, I am no longer able to update them, so the 2.5.* stable branch is not available in this form. Sorry. [i]Karim Belabas.[/i][/quote]

CRGreathouse 2011-08-03 18:18

I'm going to try to make a Windows build for them -- I have access to a Windows machine -- but it's not going to be easy. There are lots of little difficulties (and some big ones).

For now either use the development version 2.4.x or get the SVN version (up to date but no high-res graphics or readline).

3.14159 2011-08-04 15:11

I have a bit of a question..

Suppose I use this

for(n=1,20, if(random(10) > 5, print(random(10), " is > 5")

And I'd like it only to print #s > 5 (Or better yet, the first random(10))...

How exactly would I go about in doing that?

CRGreathouse 2011-08-04 20:44

Store the random number in a variable, test the variable, then print it if it's larger than 5.

science_man_88 2011-08-04 21:28

[QUOTE=CRGreathouse;268340]Store the random number in a variable, test the variable, then print it if it's larger than 5.[/QUOTE]

yeah that's how I did it in :

[CODE]randomprime(n)=until(a>10^(n-1)&&isprime(a),a=random(10^(n)-1));return(a)[/CODE]

kinda I think.

3.14159 2011-08-04 23:27

[QUOTE=CRGreathouse;268340]Store the random number in a variable, test the variable, then print it if it's larger than 5.[/QUOTE]

That's a nice step.. But I'd need it to also continuously redefine the variable for me.

What I'm trying to do is something similar to this:

[code]for(n=1,20, print(random(10)))
4
7
8
0
0
6
5
4
3
5
4
7
6
1
3
0
9
4
5
7[/code]

It printed random numbers from 0-9 (Why the hell not 1-10?? for random([b]10[/b]))

I'd like to do the above, but excluding those numbers less than or equal to 5. If it's impossible in PARI/GP, feel free to point me to where it is possible to do so. Though I'd be very disappointed if it were actually impossible to do.


All times are UTC. The time now is 22:58.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.