Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #####################################################
- # http://blogdemaths.wordpress.com
- #
- # L'autre conjecture de Goldbach
- # https://blogdemaths.wordpress.com/2015/08/28/lautre-conjecture-de-goldbach/
- #
- # Ce programme renvoie le plus petit entier impair
- # qui ne peut pas s'écrire sous la forme : p + 2a^2
- # où p est 1 ou est un nombre premier
- # et a est un entier.
- ######################################################
- import math
- def est_premier(p):
- if p==0 or p==1:
- return False
- elif p==2:
- return True
- else:
- maxi = int(math.sqrt(p))
- for k in range(2,maxi+1):
- if p%k==0:
- return False
- return True
- def autre_Goldbach(n):
- maxi = int(math.sqrt(n/2))
- for a in range(0,maxi+1):
- p=n-(2*(a**2))
- if p==1 or est_premier(p):
- #print("{} = {} + 2 x {} ^ 2".format(n,p,a))
- return True
- return False
- if __name__=="__main__":
- n=1
- while autre_Goldbach(n):
- n+=2
- print("Le nombre {} met en défaut la conjecture.".format(n))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement