ISourceCode

Make the frequent cases fast and the rare case correct

Goldbach’s conjecture

Goldbach’s conjecture is one of the oldest unsolved problems in number theory and in all of mathematics. It states: – Wikipedia

Every even integer greater than 2 can be expressed as the sum of two primes

Such a number is called a Goldbach number. Expressing a given even number as a sum of two primes is called a Goldbach partition of the number. For example,

4 = 2 + 2
6 = 3 + 3
8 = 3 + 5
10 = 7 + 3 or 5 + 5
12 = 5 + 7
14 = 3 + 11 or 7 + 7

In the article i have written a program to find the number of pairs of prime numbers are possible for every number from 4 to 20 and also 10000

import math,time
def isPrime(n):
        root = int(math.sqrt(n))
        for i in range (2,root+1):
                if n % i == 0:
                        return 0

        return 1

start = time.strftime('%s')
for n in range(4,21,2):

        count = 0
        for i in range (3,(n / 2)+1,2):
                if isPrime(i) and isPrime(n - i):
                        count = count + 1
        if n == 4:
                print n,1
        else:
                print n,count

end = time.strftime('%s')
time = int(end) - int(start)
print "Time to execute the Algorithm =", time ,"Second(s)"

OUTPUT:
labuser@ubuntu:~$ python goldbach.py
4 1
6 1
8 1
10 2
12 1
14 2
16 2
18 2
20 2
Time to execute the Algorithm = 0 Second(s)
labuser@ubuntu:~$

OUTPUT: From 4 to 10000 this can be optimized
10000 127
Time to execute the Algorithm = 200 Second(s)

Goldbach and similar conjectures were discussed in PBS Nova Series Mathematical Mystery Tour

In 2010 Prof Bob Gardner created this page as a tribute to the 25th anniversary of its airing.

In this documentary Goldbach’s conjecture is introduced in this video

I suggest seeing the full series available on youtube, it is very nice

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: