mersenneforum.org  

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

Reply
 
Thread Tools
Old 2010-09-06, 22:17   #1332
kar_bon
 
kar_bon's Avatar
 
Mar 2006
Germany

1011010111002 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
so in other terms:

Code:
forprime(p=1,1500,if(isprime(p*10^2+1),print(p*10^2+1)))
NO!

"print(p)" and that will give the correct answers!
kar_bon is offline   Reply With Quote
Old 2010-09-06, 22:20   #1333
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

69016 Posts
Default

Title is corrected.
3.14159 is offline   Reply With Quote
Old 2010-09-06, 22:21   #1334
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

20C016 Posts
Default

his sequence he gave is A180469 (already up by him) and it's not the p values it's the full values he listed.
science_man_88 is offline   Reply With Quote
Old 2010-09-06, 22:27   #1335
kar_bon
 
kar_bon's Avatar
 
Mar 2006
Germany

22×727 Posts
Default

The title says "Primes such that p * 100 + 1 is also prime."

But to which value is p*100+1 also prime?

The word "Primes" and "p*100+1 also prime" refer to different values!

"also prime" to the value p obviously meant, so p has to be listed here, not p*100+1!

PS:
And the given PARI code is also false
Code:
p10n(a, x) = { for(n=a, x, if(isprime(n)&isprime(n*10^2+1), print(10^2+1)) )};
This will ouput only 101 evertime a value is found!

Correct like this:
"Primes p such that p*100+1 also prime"
"Values: 7, 13, 19, 37, 61, 67, ..."

Last fiddled with by kar_bon on 2010-09-06 at 22:45
kar_bon is offline   Reply With Quote
Old 2010-09-06, 22:45   #1336
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

Quote:
Originally Posted by kar_bon View Post
PS:
And the given PARI code is also false
Code:
p10n(a, x) = { for(n=a, x, if(isprime(n)&isprime(n*10^2+1), print(10^2+1)) )};
This will ouput only 101 evertime a value is found!
yeah I know I've been experimenting with it lol
science_man_88 is offline   Reply With Quote
Old 2010-09-06, 22:50   #1337
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

20C016 Posts
Default

Quote:
Originally Posted by kar_bon View Post

Correct like this:
"Primes p such that p*100+1 also prime"
"Values: 7, 13, 19, 37, 61, 67, ..."
also I could see using another if to branch if(p<default(primelimit),code1,code2) type idea.
science_man_88 is offline   Reply With Quote
Old 2010-09-06, 23:35   #1338
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
also I could see using another if to branch if(p<default(primelimit),code1,code2) type idea.
How about this, for your usual preoccupation with looping over primes that 'may' be huge:

Code:
forallprime(start,stop,ff)={
  my(d=default(primelimit));
  if (type(ff) != "T_CLOSURE", error("ff must be a function! For example, forallprime(10,100,n->print(n))"));
  forprime(p=start,min(stop,d), ff(p));
  if(stop > d,
    print("\nWarning, "stop" > primelimit, calculation may be slow");
    for(n=precprime(d)+1, stop,
      if(isprime(n), ff(n))
    )
  )
};
addhelp(forallprime, "forallprime(start, stop, ff): Executes the closure (function) ff for all the primes between start and stop.");
CRGreathouse is offline   Reply With Quote
Old 2010-09-07, 00:17   #1339
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

I'm useless as this code appears to do nothing useful no matter what I do if i try to print the result it give me an error oddly if i use next() as well it doesn't give me that error but it only prints once and only exactly what I type even if it's a variable you use, plus the added bonus of not throwing a out of limits error if i go over primelimit.
science_man_88 is offline   Reply With Quote
Old 2010-09-07, 02:28   #1340
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Sorry, typo... replace T_CLOSURE with t_CLOSURE. (That'll teach me to post without checking my programs!)
CRGreathouse is offline   Reply With Quote
Old 2010-09-07, 20:59   #1341
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
Sorry, typo... replace T_CLOSURE with t_CLOSURE. (That'll teach me to post without checking my programs!)
yeah I got it working under that lol. wonder how many primes I could fit on my drives lol using my ipod and a few other removables + main drive I get

211,474,722,816
249,515,175,936
008,002,691,072
006,624,665,600
475,617,255,424 bytes if i did the math right

apparently doing math visually on here isn't a good way although I got nearly accurate I get 372 as the ending by calculator.

Last fiddled with by science_man_88 on 2010-09-07 at 21:26
science_man_88 is offline   Reply With Quote
Old 2010-09-07, 21:58   #1342
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Depends on what size primes you store and how you store them, naturally.
CRGreathouse 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:12.


Fri Aug 6 23:12:57 UTC 2021 up 14 days, 17:41, 1 user, load averages: 4.28, 4.23, 4.06

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.