20110831, 09:45  #1 
May 2011
France
7·23 Posts 
New Code
I work on the Goldback conjecture and the authors
of the verify explain that they compute the list of the prime Why in their method they need this list? N even number repeat for i:=1 to 100 M:=NPrimes(i) If IsPrime(M) then N:=n+2; until N > ????? John 
20110901, 00:48  #2 
Dec 2010
Monticello
5·359 Posts 
That bit of programming is a simple verification of Goldbach's conjecture:
"Every even number can be expressed as the sum of two primes." The program (if you add the correct braces) searches for small counterexamples. It needs some editing, since it needs to make output when it finds a counterexample, and a number of limits have been omitted. They use the list of primes as a way to avoid repeatedly testing numbers for primality. Undoubtedly, the function IsPrime() also uses the list. Last fiddled with by Christenson on 20110901 at 00:49 
20110901, 07:26  #3 
May 2011
France
A1_{16} Posts 
Thanks
To don't answer to the question
Many people use the list but why here? What is the algo use? (Sorry to use my bad english but i don't found traducer for your dialect) John N could have 1000 digits it is not a problem Last fiddled with by JohnFullspeed on 20110901 at 07:33 
20110901, 12:52  #4 
Dec 2010
Monticello
3403_{8} Posts 
Hint: I can read french, and your english translation makes things worse.
Hint: complete the program, and, for given N, tell me how many times I actually need to execute the inner loop, assuming a counterexample exists. Give me numbers with N=50. 
20110901, 19:03  #5 
May 2011
France
7·23 Posts 
Goldback
Code:
Procedure Veri_GoldBack(L:Qword); Var I,J,W:integer; M,N,R: Qword; e2: double; Label LN; begin I:=0; HH:=0; // Le nombre  le NP N:=Primes[200]+1; /// for testing Not 0 1223 a1 := GetTickCount; //timer Offset:=0; // sortie repeat LN: N:= N+2; If N>200000 then Break;// stop here j:=1; repeat HH:=NPrimes[j]; // test des divisions if not Is_Div(HH) then Goto LN; J:=J+1; until J> 20; I:=I+1; // not found until i>1000; a1 := GetTickCounta1; IsPrime: Code:
Function Is_Div(A: QWord):boolean; var i,R,S: Cardinal; E5:extended; begin Result:=True; E5:=A; R:= Round(Sqrt(E5)); i:=2; repeat If A mod Primes[i]=0 then exit; I:=I+1; until Primes[i] > r; Result:=False; end; N=1223+1 even. The step is 2 (even) and I stop at 200 000 So I do 99 383 verifs And now like Jasonp,axn,Five,silver,Bssquare... you stop to answer because your times are not in the same range that me, and you thinks that I most better that you You stop to answer. I m not better than other but it's my job. With the bad test of division I need 0,8 ... seconds Perhaps I can learn to you if you want The code is not magic The time is on my RISC for a CISC the code will be other PS can you give me the time for for i:=1 to 100000 do a=isprime(i); They all say No. 
20110901, 21:03  #6  
"Ben"
Feb 2007
7·13·41 Posts 
Quote:


20110901, 22:20  #7 
Dec 2010
Monticello
11100000011_{2} Posts 
John, slow down a bit...what language is this?
Since our hardware runs at very different speeds, depending on what else is going on on the computer, and the computer itself, we count operations, rather than clock time. And reread carefully what I asked...we need to begin with code which is correct, and do some small counting exercises before we start trying to time things. I can compute anything faster than you if it doesn't have to be right!!! What you have there is called a mess...and a classic example of what I was talking about in terms of giving people the wrong idea about you. In particular, suppose Goldbach's conjecture is false for N=50. How long will the program run, and how would we know if Goldbach's conjecture is false from looking at the output of the code? I suggest you restart from the original fragment you copied into this thread. 
20110902, 03:31  #8 
Romulan Interpreter
"name field"
Jun 2011
Thailand
2×3^{2}×571 Posts 
Code:
begin N:=Primes[200]+3; /// for testing Not 0 1223 {you better do postincrement of it} a1 := GetTickCount; //timer repeat j:=0; {here preincrement works better, to exit the loop when is found} repeat J:=J+1; until (J>200) or not Is_Div(NPrimes[j]); {not 20, as in your program} N:=N+2; until N>20000; {not 1000!} a1 := GetTickCounta1; {printing stuff} end; That is, the 20th prime is 71. Your program was checking if an even number in the interval 1226..3226 (in Pascal notation) can be written as a sum of a prime smaller then 72 and another prime. That's all. You could check that much easier and faster in Pascal using "set" operators (Pascal can do a lot of stuff with sets of objects). See how much time do you need if you give the right values for limits, like I modified above in your code, and anyhow this won't be enough correct to verify Goldbach, if you want to go to N=200000 then you have to store the primes to 100000, just in case you run in some number which is a sum of two primes of about the same size (try playing on some superior limit of a very large prime gap). But for the solely purpose of timing, you should use the right number of iterations.... Tip: If you just copy the codesnap from above, be careful how you set the compiler's behaviour of evaluating boolean expressions, otherwise you could get an "array out of bounds" when you evaluate Primes[201] for j=201 at the most inner loop. Last fiddled with by LaurV on 20110902 at 03:43 
20110902, 12:14  #9 
May 2011
France
A1_{16} Posts 
The original question is:
Why Zimmerman need to compute the primelist to verify Golback In a Brute force method like thyis(I never say thatt I use it, that it is speederr orr anything like this Christenson answer that the Brute force method is bad but don't give a method using prime list To prove that the brute force method is false He say me try the sample withs N=50 maxi I understand that he want to see how many time the brute force needs to verif that all even numbers <52 can be write like a sum I write a little code to find I do'nt say that I use It but I compute the time For those that think that they are better than bullshiit I add a vector with the 25 sums. Before to give lessons on Pascal open a book http://en.wikipedia.org/wiki/Turbo_Pascal Historically, Pascal comments are indicated { like this }, or (* like this *), and these can span any number of lines. Later versions of Borland Pascal also supported C++style comments // like this, which finish at the end of the line. You forget to give the name of your Pascal compiler that you use to try the code You see Christenson : no code publish, no times and more simple I never Use pascal But when I ask how many time you need no answer: just bullshit You are speeder than me : show me . You give the math problem: Choose an hard problem for the computer or a classic suject: twin search,Aliquot,factorisation You can use all the library you want the langage you want To give me a handicap I make a version on windows 32. or You know that my job is to make YOUR code better for the computer without change the math So write a code publish it An every one can optimize it I take the challenge to go 2 time speeder than you only because I know well the computer I said 2 but I thinks 5... Before to say that I m bullshit try: I wait your code And don't forget it's the computer which make tiime not the coder In this version N <50 but the chrono doesn't move I set N to 10000 to have a small time 0,050 second But it's easy to make many more faster without bullshit Procedure Veri_GoldBack(L:Qword); Var I,J,W:integer; M,N,R: Qword; Label LN; begin HH:=0; N:=0; // Begin with N=0 a1 := GetTickCount; //timer repeat LN: N:= N+2; If N> 50 then Break;// stop when N > 50 j:=1; repeat HH:=NPrimes[j]; // test des divisions if odd(hh) then // speeder for mod 2 and mod 5 if not Is_Div(HH) then begin Q[N1]:= N;// the sum Q[N]:= hh;// a prime Goto LN; end; J:=J+1;// No limit to J until Primes[j] > N; // overflow N<0 I:=I+1; // not found NotFound[i] :=N; //if the Goldbak is false you arrive here and can stop until false; // infinity loop a1 := GetTickCounta1; end; 
20110902, 14:15  #10  
Dec 2010
Monticello
5×359 Posts 
Quote:
@Laurv: The first program could work, if the braces in the original (or the begin/end pairs) had been preserved, and the code that would execute if Goldbach's conjecture were to prove false were included. John has completely lost it with the second program...it's hopeless and not even worth debugging. @John 1) I haven't said bruteforce is good or bad....it's just one more tool.....we all work in terms of properties of the programs. (If you think I think brute force is bad, you have to ask why I have a high rank at TF, which is a bruteforce method...) 2) I wanted you to give the original program...I promise you that what you posted wasn't it. This way we can CHECK your analysis. 3) I wanted you to analyse the original program, in terms of what would happen if, say, 50 was a counterexample to Goldbach's conjecture. How many loops would be required? 4) Talk about the program, not the people. Improve the program....get it right FIRST AND FOREMOST. 

20110902, 17:28  #11 
May 2011
France
7×23 Posts 
Word...
Where is your code ? I don't search juge but idea
But you are not an 'intlectual ' You need concret (French expression not insult) I verify the conjecture with 0 < N < 1 223 193 544 (( 10^ 9) I need 1' 32 (I can give all the sums: no need of verify) It's slow? You are far? How many works before joint the WC of the forum PS Don't say it to Christensen : the code use only 6 lines In the version I use prime list: I found a use( not the use of Zimmer) I wait code... 
Thread Tools  
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Rho code  Happy5214  YAFU  3  20151101 21:54 
Please help me with my code  daxmick  Programming  15  20140214 11:57 
Code Help  Andrew  Programming  12  20130216 20:53 
Code  Primeinator  Software  20  20090611 22:22 
A little help with VBS code  IronBits  No Prime Left Behind  6  20081112 14:23 