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)

3.14159 2010-08-19 19:17

I'm leaning towards the latter being true.

@sm88: Too many arguments, failed to specify whether or not a=1 was part of the command, a=1 treated as its own command

science_man_88 2010-08-19 19:23

[QUOTE=3.14159;226216]I'm leaning towards the latter being true.

@sm88: Too many arguments, failed to specify whether or not a=1 was part of the command, a=1 treated as its own command[/QUOTE]

it should be it's own command. it's only when i used concat() that this happened.

CRGreathouse 2010-08-19 19:29

[QUOTE=3.14159;226214]Nope. I changed nothing. It was either incredible luck or the computer fucking up.[/QUOTE]

I'm leaning toward "you used a as a variable in a function without using local or my" which would explain it pretty well.

CRGreathouse 2010-08-19 19:30

[QUOTE=3.14159;226216]@sm88: Too many arguments, failed to specify whether or not a=1 was part of the command, a=1 treated as its own command[/QUOTE]

[QUOTE=science_man_88;226217]it should be it's own command. it's only when i used concat() that this happened.[/QUOTE]

I don't know what either of these mean.

3.14159 2010-08-19 19:36

[QUOTE=CRGreathouse]I'm leaning toward "you used a as a variable in a function without using local or my" which would explain it pretty well.
[/QUOTE]

Nope. I defined f(x, n) as follows:

Print nextprime(x), followed by * , followed by nextprime(n), followed by printing the product of those two. In other words, a semiprime generator that gives the factors used to produce the semiprime as well.

a(n) = nextprime(random(10^n)).

a and f were well-defined. a was never a variable, it is a function.

a simply gives an n-digit prime most of the time.

Therefore, there was no error in my defined functions.

science_man_88 2010-08-19 19:37

[CODE] v=vector(1250,n,0);a=1;for(x=1,10000,if(isprime(x),v[a]=x;a=a+1))[/CODE]

works but you already have to know the # of primes under the x upper bound to not get an error or a 0 at the end.

what I want to do is add a 0 into v every time a prime is found so as to have no 0's at the end of it all and to only have the number of indices necessary to list all the primes under a given number once the vector is made I can get a sieve like the sieve of Eratosthenes to try and work with it to create a bigger list instead of asking isprime hopefully I can make a way to check primality quicker and then make a function that uses the vector indices to check Prime2(x).

3.14159 2010-08-19 19:39

[QUOTE=CRGreathouse]I don't know what either of these mean.
[/QUOTE]

I was merely trying to explain sm88's error.

CRGreathouse 2010-08-19 19:39

[code]v=vector(1,n,0);
a=1;
for(x=1,10000,
if(isprime(x),
v[a]=x;
concat(v[],0);
a=a+1
)
)[/code]

I'm not sure what "concat(v[],0);" is trying to do, but it's not right. v[] will cause an error. If you replace v[] with something that isn't an error, like v, then the result would take v and concatenate it with 0, then throw the result away. Maybe you mean

[code]v=concat(v,0);[/code]

which would take v, append 0 to the end, and replace the old v with the "old v followed by a 0" vector.

Here's how I would do what I think you're trying to do:
[code]v=[];
for(x=1,10000,
if(isprime(x),
v=concat(v,x)
)
)[/code]
or even
[code]v=[];
forprime(p=2,10000,
v=concat(v,p)
)[/code]
or even
[code]v=vector(primepi(10000));
i=0;
forprime(p=2,10000,
i++;
v[i]=p
)[/code]
which I would usually write in the confusing programmer-ese as
[code]v=vector(primepi(10000));
i=0;
forprime(p=2,10000,
v[i++]=p
)[/code]

CRGreathouse 2010-08-19 19:40

[QUOTE=3.14159;226220]Nope. I defined f(x, n) as follows:

Print nextprime(x), followed by * , followed by nextprime(n), followed by printing the product of those two. In other words, a semiprime generator that gives the factors used to produce the semiprime as well.

a(n) = nextprime(random(10^n)).

a and f were well-defined. a was never a variable, it is a function.

a simply gives an n-digit prime most of the time.

Therefore, there was no error in my defined functions.[/QUOTE]

Did you put in ?a ? What did it say?

science_man_88 2010-08-19 19:46

now if I only I could be smart like you so I could build you that helpful program lol.

3.14159 2010-08-19 19:59

[QUOTE=CRGreathouse]Did you put in ?a ? What did it say?
[/QUOTE]

?a = a(n) = nextprime(10^n))


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

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