mersenneforum.org  

Go Back   mersenneforum.org > Math Stuff > Computer Science & Computational Number Theory > PARI/GP

Reply
 
Thread Tools
Old 2010-08-19, 19:17   #694
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

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

Last fiddled with by 3.14159 on 2010-08-19 at 19:19
3.14159 is offline   Reply With Quote
Old 2010-08-19, 19:23   #695
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
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
it should be it's own command. it's only when i used concat() that this happened.
science_man_88 is offline   Reply With Quote
Old 2010-08-19, 19:29   #696
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
Nope. I changed nothing. It was either incredible luck or the computer fucking up.
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 is offline   Reply With Quote
Old 2010-08-19, 19:30   #697
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
@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:
Originally Posted by science_man_88 View Post
it should be it's own command. it's only when i used concat() that this happened.
I don't know what either of these mean.
CRGreathouse is offline   Reply With Quote
Old 2010-08-19, 19:36   #698
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

Quote:
Originally Posted by 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.
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.

Last fiddled with by 3.14159 on 2010-08-19 at 19:38
3.14159 is offline   Reply With Quote
Old 2010-08-19, 19:37   #699
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Code:
 v=vector(1250,n,0);a=1;for(x=1,10000,if(isprime(x),v[a]=x;a=a+1))
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).
science_man_88 is offline   Reply With Quote
Old 2010-08-19, 19:39   #700
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

Quote:
Originally Posted by CRGreathouse
I don't know what either of these mean.
I was merely trying to explain sm88's error.
3.14159 is offline   Reply With Quote
Old 2010-08-19, 19:39   #701
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

10111010110112 Posts
Default

Code:
v=vector(1,n,0);
a=1;
for(x=1,10000,
  if(isprime(x),
    v[a]=x;
    concat(v[],0);
    a=a+1
  )
)
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);
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)
  )
)
or even
Code:
v=[];
forprime(p=2,10000,
  v=concat(v,p)
)
or even
Code:
v=vector(primepi(10000));
i=0;
forprime(p=2,10000,
  i++;
  v[i]=p
)
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
)
CRGreathouse is offline   Reply With Quote
Old 2010-08-19, 19:40   #702
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
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.
Did you put in ?a ? What did it say?
CRGreathouse is offline   Reply With Quote
Old 2010-08-19, 19:46   #703
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

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

Last fiddled with by science_man_88 on 2010-08-19 at 19:46
science_man_88 is offline   Reply With Quote
Old 2010-08-19, 19:59   #704
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

Quote:
Originally Posted by CRGreathouse
Did you put in ?a ? What did it say?
?a = a(n) = nextprime(10^n))
3.14159 is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do I sometimes see all the <> formatting commands when I quote or edit? cheesehead Forum Feedback 3 2013-05-25 12:56
Passing commands to PARI on Windows James Heinrich Software 2 2012-05-13 19:19
Ubiquity commands Mini-Geek Aliquot Sequences 1 2009-09-22 19:33
64-bit Pari? CRGreathouse Software 2 2009-03-13 04:22
Are these commands correct? jasong Linux 2 2007-10-18 23:40

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


Fri Aug 6 23:06:20 UTC 2021 up 14 days, 17:35, 1 user, load averages: 4.38, 3.93, 3.93

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

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.