![]() |
[QUOTE=CRGreathouse;222470]This code shows that there is some Goldbach partition for some even number up to 400000, not that every even number up to 400000 has a Goldbach partition. It's faster by doing far less.[/QUOTE]
I realize that now lol in fact it only proves one. |
[QUOTE=3.14159;222464]Also: If 6n+1, 12n+1, and 18n+1 are prime, (6n+1)(12n+1)(18n+1) = Carmichael number.
My best guess: (6n+1)(12n+1) = 72n^2 + 6n + 12n + 1 = 72n^2 + 18n + 1 (18n+1)(72n^2 + 18n + 1) = 1296n^3 + 72n^2 + 324n^2 + 18n + 18n + 1 That = 1296n^3 + 396n^2 + 36n + 1[/QUOTE] Pari can do that for you if you'd like: [code]>(6*n+1)*(12*n+1)*(18*n+1) time = 0 ms. %1 = 1296*n^3 + 396*n^2 + 36*n + 1[/code] [QUOTE=3.14159;222464]I need a bit of assistance here.. [code](13:20) gp > b(n) = { for(n = 10^3, 3*10^3,(1296*n^3 + 396*n^2 + 36*n + 1, if(numdiv(1296*n^3 + 396*n^2 + 36*n + 1) == 8, print(n))); }[/code] [code]*** syntax error, unexpected ')', expecting KPARROW or ',': ...*n^2+36*n+1)==8,print(n)));[/code][/QUOTE] The error says that your parentheses don't match. If I just delete the portion "(1296*n^3 + 396*n^2 + 36*n + 1," which has the unmatched parenthesis, it works. You shouldn't take n as a parameter, though, since you don't use it. Doubly so since your loop variable is n and it looks confusing. You may want to take a variable that says how high to go, though -- I usually call such variables "lim". So: [code]b(lim)={ for(n = 10^3, lim, if(numdiv(1296*n^3 + 396*n^2 + 36*n + 1) == 8, print(n)) ); };[/code] But this is inefficient in the extreme: instead of doing a primality test on three numbers around n, you factor a number around n^3. Do this: [code]b(lim)={ for(n = 10^3, lim, if(isprime(6*n+1)&isprime(12*n+1)&isprime(18*n+1), print(n)) ); };[/code] This way: * You're doing isprime() instead of factoring a number, which is vastly faster; * You can exit the loop early if any one of the tests fails. |
I once again search for generalized Fermat primes (Exponent = 256), and for misc. primes. (Factorial-based, etc.). So far, the largest Generalized Fermat I have ever found is also the second-largest prime number I have ever found. (13050 digits)
|
[QUOTE=3.14159;222495]I once again search for generalized Fermat primes (Exponent = 256), and for misc. primes. (Factorial-based, etc.). So far, the largest Generalized Fermat I have ever found is also the second-largest prime number I have ever found. (13050 digits)[/QUOTE]
Does GFN mean "of the form [TEX]b^{2^n}[/TEX]"? Because in that case all 256-GFNs are Fermat numbers... |
[QUOTE]Does GFN mean "of the form b[sup]2[sup]n[/sup][/sup] "? Because in that case all 256-GFNs are Fermat numbers...[/QUOTE]
No: I meant, n[sup]256[/sup]+1. I did not use base 256, and yes: Generalized Fermats are of the form b[sup]2[sup]n[/sup][/sup], where b does not have to be 2 or any of its powers. |
PrimeForm is usually the best exploratory tool for primes like that, though if you have a 13 kilodigit under your belt I suppose you don't need any advice. :wink:
|
[QUOTE]PrimeForm is usually the best exploratory tool for primes like that, though if you have a 13 kilodigit under your belt I suppose you don't need any advice. [/QUOTE]
It's the second-largest. The definite largest is 59991 * 2[sup]91360[/sup] + 1 (27507 digits) |
a=0;forstep(n=2,400,[2],forprime(x=2,n/2,if(isprime(floor((.5*n-x)+(.5*n))),print(x","floor((.5*n-x)+(.5*n))","n));a=a+1;if(a>0,break()))) this is the best I could do for what I pm'd you but it only seems to work once.
|
[QUOTE=science_man_88;222564]a=0;forstep(n=2,400,[2],forprime(x=2,n/2,if(isprime(floor((.5*n-x)+(.5*n))),print(x","floor((.5*n-x)+(.5*n))","n));a=a+1;if(a>0,break()))) this is the best I could do for what I pm'd you but it only seems to work once.[/QUOTE]
Please use [[i][/i]code] tags and format your code! It's hard to read all bunched up like that. [code]a=0; forstep(n=2,400,[2], forprime(x=2,n/2, if(isprime(floor((.5*n-x)+(.5*n))), print(x","floor((.5*n-x)+(.5*n))","n) ); a=a+1; if(a>0,break()) ) )[/code] There's no reason to give the step size as a vector if there's only one element, so I'll remove that. I also see that you use floor((.5*n-x)+(.5*n)) twice, so let's save that in a variable. (In this case it doesn't make the code any faster, really, but it's much more readable.) Also, "a=a+1" can be rewritten as "a+=1" (add 1 to a) or, even shorter, as "a++" in the particular case of adding exactly one. [code]a=0; forstep(n=2,400,2, forprime(x=2,n/2, f=floor((.5*n-x)+(.5*n)); if(isprime(f), print(x","f","n) ); a++; if(a>0,break()) ) )[/code] Now you can see that you add one to a then immediately test if it's greater than zero; you can simply replace the test and use of a with an unconditional break. [code]forstep(n=2,400,2, forprime(x=2,n/2, f=floor((.5*n-x)+(.5*n)); if(isprime(f), print(x","f","n) ); break() ) )[/code] Now you can see that you're breaking out after only testing to see if (n/2-2)+(n/2) = n-2 is prime. Of course it's only showing one... this can happen only if n-2 is an even prime. The best way to fix it is to break out that portion as its own function: [code]Gold(n)={ forprime(x=2,n/2, f=floor((.5*n-x)+(.5*n)); if(isprime(f), print(x","f","n); return(); ); ) }; forstep(n=2,400,2,Gold(n))[/code] Of course the 'right' way is to have the function return the prime it finds and have the print statement in your forstep code, so that you can do other things with the result beside print it. For example, maybe you want to look only for large values? |
[QUOTE=CRGreathouse;222568]
[code] forstep(n=2,400,2, forprime(x=2,n/2, f=floor((.5*n-x)+(.5*n)); if(isprime(f), print(x","f","n) ); break() ) ) [/code] [/quote] f = .5*n-x + .5*n ??? So f = n-x !? I think the original form was like : [code] if(isprime(.5*c+n) && isprime(.5*c-n) [/code] So assuming this was meant: If I'm understand this correct (not yet coded with PARI), the forstep-loop chooses only even values of n. Correct? And to calculate the value f it uses 2-times the expression '.5*n'. So why not using all n-values and check for isprime(c+n) && isprime(c-n). Should be much faster without two multiplications. The output has to be changed then, too. |
[QUOTE=kar_bon;222571]f = .5*n-x + .5*n ???
So f = n-x !?[/QUOTE] You'll have to take that up with science_man_88. I keep suggesting things like that, but he likes the 0.5*n forms because of some connection with the interpretation of equally-spaced primes from 0.5*n. (sm88: if you do n/2 rather than 0.5*n you can avoid using floor().) You can see his original code in post #151; I'm just cleaning it up. [QUOTE=kar_bon;222571]If I'm understand this correct (not yet coded with PARI), the forstep-loop chooses only even values of n. Correct?[/QUOTE] Right. [QUOTE=kar_bon;222571]And to calculate the value f it uses 2-times the expression '.5*n'. So why not using all n-values and check for isprime(c+n) && isprime(c-n). Should be much faster without two multiplications.[/QUOTE] Yep. Been there, done that; see post #62. |
| All times are UTC. The time now is 20:22. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.