# Générateur de nombres premiers def primes () : known_primes = [2, 3] yield 2 yield 3 p = 5 while True : is_prime = True for pp in known_primes : if pp * pp > p : break if p % pp == 0 : is_prime = False break if is_prime : known_primes.append(p) yield p p += 2 # Recherche du plus petit nombre premier supérieur à 2^6 def main(): ip = primes() cp = next(ip) while cp <= 2**6 : cp = next(ip) print(cp) # Calcul de g^k mod p pour k variant de 0 à kmax inclus def gkmodp(g, p, kmax) : for k in range(kmax+1) : print((g**k)%p) import math # Calcul du coût du logarithme discret def costdisclog(p): k = (64/9)**(1/3) return math.exp(k*(math.log(p))**(1/3)*(math.log(math.log(p))**(2/3)))
Code python pour le TD n°5 de SIP