Goldbach Program Documentation

          Documentation for Goldbach's Conjecture Program

I have developed a computer program to investigate Goldbach's conjecture. My 
plan was to determine if for large n there are many decompositions of 2n into 
the sum of two primes.

When you execute the program Goldbach.exe you get the message:

    Goldbach - Computes number of ways 2n = pi+pj (pi, pj primes pi<=pj
    It using the sieve of Eratosthenes with double Floating-point.
    C# Version
    Copyright (c) 1981-2007 by author: Harry J. Smith,
    19628 Via Monte Dr., Saratoga CA 95070.  All rights reserved.

 This program computes terms for The On-Line Encyclopedia of Integer
 Sequences maintained by N. J. A. Sloane. See:

 The sequence generates is:
 A135733 1,6,34,64,76,94,166,199,244,244,316,346,496,496,556,556,556,706,706,

 For every integer m > a(n), 2m can be decomposed into at least n unordered sums
 of two primes. Goldbach's conjecture is equivalent to the case when n = 1, a(1)
 = 1, but for large n there appears to be many decompositions guaranteed. This
 sequence relies on a heuristic calculation and there is no proof that it is


 The latest version of this program and all of its source files can be
 downloaded from .

Goldbach's Conjecture in Euler's form is
Every even integer 2n >= 4 is the sum of two primes.

But for large n there appears to be many decompositions guaranteed.

The program uses a Function NPrime(mC) to generate consecutive prime numbers. It 
is an implementation of Algorithm 357 of the Collected Algorithms from ACM. It 
is an efficient prime number generator using the sieve of Eratosthenes. Here mC 
= Number of new primes desired this call. The current length of the tables in 
array iQ and jQ is returned. This is approximately the number of primes < 
sqrt(current prime). It must not exceed qSize, referred to as "Prime # Table 
Length" on the opening Startup form when you start the program. The user can set 
qSize to any value 1 <= qSize <= 2^31-1. Values less than 200 produce no output. 
Numbers greater than about 10000000 give an out-of-memory alarm. The default 
value is 1000000.

The next parameter on the Startup form is rSize "Size of Result Table". The 
default value is 500. The result table is used to store new values of the 
sequence as it is computed and the time it took to compute it. If you intend to 
compute many terms, you need a value of rSize at least 100 or so. It is not 
known how large it must be for extremely long calculations. If the program stops 
with "Numbers got too large!" message due to qSize or rSize being too small, the 
program can be restarted with a larger qSize and/or rSize. Just do a "Read 
SnapShot" after the program gets started.

The user can also control mC, the number of primes generated by NPrime. This is 
called "Primes Gen. Per Cycle" on the Startup form. The default value is 105000, 
but the user can change it to any value 2 <= mC <= 2^31-1. Values much larger 
than the nominal are not recommended.

The next parameter on the Startup form that the operator can change is cyc 
"Cycles Per Status". Its default value is one, but cyc be changed to any value 1 
<= cyc <= 1000. Large values on cyc produce fewer status updates.

The last parameter on the Startup form that the operator can change is Execution 
Priority. It can be set to an integer Pri, -2 <= Pri <= 2. With 2 = Highest, 1 = 
AboveNormal, 0 = Normal, -1 = BelowNormal, -2 = Lowest. Its default value is -1.

These five values are tested as they are edited. Spaces on the left or right are 
removed so you will not see them. These numbers are displayed in bold face font 
iff they are acceptable values. If any of the values are unacceptable, the Run 
button is disabled.

A "Default Settings" button is provided to reset the five parameters to their 
original values.

There are also two command buttons on the Startup form "Run" and "Exit". Choose 
"Exit" to totally terminate the program. Choose "Run" to bring up the second or 
Run form and start calculations.

The Run form will start calculations and start updating status, like:

      The system was booted-up x/xx:xx:xx ago.

      Priority is BelowNormal
      Current array index: 4 5 6 7 ...

The priority is set to BelowNormal so you can continue using your computer to do 
other tasks. The status is the output of ai the "Current array index" which is 
the last index from 1 to rSize where the last term of the computed sequence was 
stored. Every time a new term is computed, the new term is stored over any 
earlier term that has just been proven not to belong in the table.

Other status items are, for example "Prime no. table length = 193 of 10000", 
"Current result array index = 74 of 500" and "Max prime tested = 16,603". The 
prime no. table is the array of all primes less than the square root of the last 
prime generated by the function NPrime. The Current results array index is the 
same as described in the last paragraph but here we also get the max length of 
the array, rSize. The max prime tested is just that.

There are six command buttons for controlling the actions of the program. They 
are "Read SnapShot", "Write Snapshot", "Write Results", "Test 'Too Large'", 
"Pause", and "Quit".

Write SnapShot: Selecting this will write a snapshot file containing all the 
data that is necessary to initialize and restart the programs calculations 
exactly where it was when the snapshot was taken. It contains all of the data in 
the results table. When a snapshot file is written, the previous snapshot file, 
if any, is renamed GoldbachSnapS.Bak and a new file is named GoldbachSnapS.txt. 
An automatic Write SnapShot is forced every hour and when "Numbers got too 

Read Snapshot: This will read the latest snapshot file GoldbachSnapS.txt and 
restart the calculations from there. If the snapshot file has a "Size of Result 
Table" >= the current value, it is set to twice the snapshot file value.

Write Results: This will write a file containing the results table in a human 
readable form. When a results file is written, the previous results file, if 
any, is renamed GoldbachRFile.Bak and a new file is named GoldbachRFile.txt.

Test 'Too Large': This causes the program to try to store a zero in one cell 
pact the end of the result table. This simulates the numbers getting too large 
for the program to handle in its current configuration. The program will then 
write a results file to GoldbachRFile.Too and "Quit".

Pause: This causes the program to stop using processor resources and wait to be 
resumed. When resumed by selecting OK on the message box provided, the amount of 
time delayed is accounted for to maintain an accurate value of the time required 
to calculate the terms of the sequences.

Quit: This does cause the calculations to stop and the user is returned to the 
original Startup form for possible restart "Run" or termination "Exit".

The functions of the six command buttons are also available in the "File" menu. 
Minimize and Close buttons are also available. The Close button does the same as 
the "Quit" and the "Exit" in the "File" menu. The "File" menu also has a "Write 
All" function which does a "Write Results" followed by a "Write SnapShot".

Next to the "File" menu is the "Priority" menu which contains a selection of the 
five execution priorities. One of these five are always marked with a radio 
button to show the current priority.

Next to the "Priority" menu is the "Help F1" menu which contains "Help Form" and 
"About". The "About is obvious. Pressing F1 or selecting "Help Form" brings up a 
third or Help form containing this help text that can be scrolled up and down to 

This Help form has a "File" menu that has the options "Print Setup", "Print", 
"Print Preview" and "Exit". These are straightforward. The Exit merely exits 
this Help form. The calculations have continued during the Help session.

To install, copy the files Goldbach.exe and GoldbachHelp.txt to any folder and 
execute the .exe file from there. For development, the following 16 files are 


The program can generate the following 5 files:

   GoldbachRFile.Bak  Copy of previous PrimeSRcsRFile.txt file
   GoldbachRFile.Too  Results in a data table when "Numbers got too large!"
   GoldbachRFile.txt  Results in an accumulated data table
   GoldbachSnapS.Bak  Copy of previous PrimeSRcsSnapS.txt file
   GoldbachSnapS.txt  Snap Shot of all data for restart, forced every hour

The latest version of the program as well as the latest results and restart 
files can be downloaded from my website: 

The end -

Report any errors by sending me a letter, an e-mail or call me at my home phone.


Harry J. Smith
19628 Via Monte Dr.
Saratoga, CA 95070-4522, USA

Home Phone:  1 408 741-0406

Return to Goldbach's Conjecture
Return to Harry's Home Page

This page accessed times since November 25, 2007.
Page created by:
Changes last made on Wednesday, 05-Dec-07 15:13:58 PST