Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ####################################################
- #
- # Blogdemaths - Factorisation des nombres de Fermat
- #
- # https://blogdemaths.wordpress.com/2016/02/07/nombres-de-fermat-1ere-partie-comment-euler-a-factorise-f5/
- #
- ####################################################
- def FermatLucas(n):
- """ Renvoie le plus petit diviseur premier du nombre de Fermat 2^(2^n)+1 """
- #Nombre de Fermat
- F=2**(2**n)+1
- #Diviseur premier potentiel
- k=1
- deuxnplusdeux = 2**(n+2)
- p= deuxnplusdeux+1 #p=2^(n+2)+1 au départ
- while not(F%p==0):
- p+=deuxnplusdeux
- k = (p-1)//deuxnplusdeux
- print(("F{} est divisible par "+str(p)+" = {} x 2^"+str(n+2)+" + 1").format(n,k))
- #print("On a la factorisation:\nF{} = {} x {}".format(n,p,F//p))
- return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement