Created
August 5, 2015 19:06
-
-
Save viveksyngh/a2f1168595ed42e23c93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Given an even number ( greater than 2 ), return two prime numbers whose sum will be equal to given number. | |
def primesum(n): | |
for i in xrange(2, n): | |
if is_prime(i) and is_prime(n - i): | |
return i, n - i | |
def is_prime(n): | |
if n < 2: | |
return False | |
for i in xrange(2, int(n**0.5) + 1): | |
if n % i == 0: | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment