[ create a new paste ] login | about

Link: http://codepad.org/eNhwPeih    [ raw code | output | fork ]

swapnilghorpade - Python, pasted on Dec 15:
#Christian Goldbach (1690-1764) was a
#Prussian mathematician and contemporary of Euler.
#One of the most famous unproven conjectures in number theory is
#known as Goldbach’s Conjecture, which states that every even number
#greater than two is the sum of two prime numbers;
#for example, 28 = 5 + 23.

#function to check prime
import array 
def isprime(k):
    for j in range(2,k-1):
        if (k%j==0):
            return 0
    return 1    
#function to print set of a prime 
def primes(n):
    j=0
    set1=array.array('b')
    for i in range(1,n):
        if(isprime(i)):
            set1.append(i)
            j=j+1    
    print set1.tolist()
    l=len(set1)
    
    for i in range(0,l):
        for k in range(i,l):
            j=set1[i]+set1[k]
            if j==n:
                print set1[i],set1[k]
#main starts here
m=int(raw_input('Enter A even no gretar than 2'))
if (m<=2 |(m%2==0)):
    print 'wrong input'
    exit(0)
primes(m)    
    





        


Output:
1
2
  Line 4
SyntaxError: Non-ASCII character '\xe2' in file t.py on line 4, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details


Create a new paste based on this one


Comments: