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)

science_man_88 2010-08-19 18:21

scratch f we can just use v=f to redefine it back to v after.

CRGreathouse 2010-08-19 18:22

[QUOTE=science_man_88;226201]CRG I got my code to work to find primes and fill a vector of 0's with them I'm thinking of how to make a function VecApp(v,x,f) that takes one vector(v) into another vector(f) with 1 extra element which is appended with value x maybe that will make it easier on me. I think this would need to say something like f[i] = v[i] f[i]+1 = x but I'm without reading them all I have no idea how to get i not to go over the amount of indexes of v.[/QUOTE]

[code]concat([1,2,3],10)[/code]

science_man_88 2010-08-19 18:23

I'm an idiot thanks.

3.14159 2010-08-19 18:25

[QUOTE=CRGreathouse]Just look at my code for how to use the vector!
[/QUOTE]

my(v=vectorsmall(sz, i, 1))?

What is supposed to be the substitution here?

CRGreathouse 2010-08-19 18:26

[QUOTE=science_man_88;226205]I'm an idiot thanks.[/QUOTE]

You were trying to write a function that already existed. That's pretty common. I wrote my own version of eint1, at the very least -- but probably others, too.

3.14159 2010-08-19 18:31

A 1 in 10[sup]65[/sup] chance:

I entered a(65), which is nextprime(random(10^65)). The result: 2.

CRGreathouse 2010-08-19 18:35

Well, 3 in 10^65 anyway. Wow.

3.14159 2010-08-19 18:56

[QUOTE=CRGreathouse]Well, 3 in 10^65 anyway. Wow.
[/QUOTE]

It was in fact, too good to be true. It turned out PARI was messed for a while.

I entered a(7) and got 2, 6 times in a row. I tried a(8) through a(12), and got 2, about 20 times on end.

This would normally happen only about 1 in ≈10[sup]163[/sup] times. I'm going with PARI being a bit buggy. Or did I have a supreme stroke of luck and just defy odds of 1 in 10[sup]163[/sup]?

Also: The lottery should be changed to guessing 10 random numbers between 1 and 10[sup]15[/sup].

(To ensure that nobody wins, :devil:)

CRGreathouse 2010-08-19 19:10

You may have inadvertently overwritten a. Try ?a to see the current definition.

3.14159 2010-08-19 19:15

[QUOTE=CRGreathouse]You may have inadvertently overwritten a. Try ?a to see the current definition.
[/QUOTE]

Nope. I changed nothing. It was either incredible luck or the computer fucking up.

science_man_88 2010-08-19 19:16

[CODE](15:27) gp > v=vector(1,n,0);a=1;for(x=1,10000,if(isprime(x),v[a]=x;concat(v[],0);a=a+1))
[COLOR="Red"]*** unused characters: v=vector(1,n,0);a=1;for(x=1,10000,if(is
^--------------------[/COLOR][/CODE]


All times are UTC. The time now is 23:07.

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