diff --git a/TP2_bonus_MandelBrot/Bigpicture.png b/TP2_bonus_MandelBrot/Bigpicture.png index 3cbbae2..06779ee 100644 Binary files a/TP2_bonus_MandelBrot/Bigpicture.png and b/TP2_bonus_MandelBrot/Bigpicture.png differ diff --git a/TP2_bonus_MandelBrot/main.py b/TP2_bonus_MandelBrot/main.py index b877fc1..9ad2399 100755 --- a/TP2_bonus_MandelBrot/main.py +++ b/TP2_bonus_MandelBrot/main.py @@ -148,6 +148,6 @@ def bigpicture(n=2, size=128): new_im.paste(images.pop(0), (int(window[1][0]), int(window[0][0]))) new_im.save('Bigpicture.png') -bigpicture(n=3, size=512) +bigpicture(n=3, size=1024) #mandeld(n=512, lim=255, color=(1,1,1), threads=10, window=[(-2,2),(-2,2)]) #[((-2.0, 0.0), (-2.0, 0.0)), ((-2.0, 0.0), (0.0, 2.0)), ((0.0, 2.0), (-2.0, 0.0)), ((0.0, 2.0), (0.0, 2.0))] diff --git a/TP3/TP 3 etudiants.py b/TP3/TP 3 etudiants.py new file mode 100755 index 0000000..c03431f --- /dev/null +++ b/TP3/TP 3 etudiants.py @@ -0,0 +1,113 @@ +######Exercice 1 ###### +from math import* +##Question 1:## + +def multiplesde7(n): + l=[] + for i in range(n): + if i%7==0: + l+=[i] + return l + + +print(multiplesde7(100)) + + +##Question 2## + +Un nombre (n) est premier si aucun nombre inferieur a sqrt(n) en divise (n). +On vérifie ici ce théoreme en testant sucessivement la divisibilité des (i) par (n) avec (i) variant de 2 a sqrt(n) + +##Question 3## + +def isprime(n): + s=int(sqrt(n)) + t=True + i=2 + while i<=s and t==True: + if n% i==0: + t=False + i+=1 + return(t) + +def listepremier(n): + l=[] + for i in range(2,n+1): + if isprime(i): + l+=[i] + return l + +##Question 4## +def premier(): + p=[] + n=2 + while len(p)!=100: + if isprime(n): + p+=[n] + n+=1 + return p + +##Question 5## + +def jumeaux(): + l=[] + for i in range(2,3000): + if isprime(i) and isprime(i+2): + l+=[(i,i+2)] + return l + +##Question 6# + +n=0 +while 1<2: + a=2**(2**n) +1 + if isprime(a) == False: + print(False, n) + break + n+=1 +## Question 7 BONUS (à traiter plus tard) ## + +######Exercice 2###### + +##Question 1## +a=1 +print(a) +for i in range(100): + b=(1/2)*(a+(2/a)) + print(b) + a=b + +##Question 2## +a=1 +print(a) +for i in range(10): + b=(1/2)*(a+(2/a)) + print((b)**2 - 2) + a=b +# les valeurs tendent très rapidement vers 0 car sqrt(2)**2 - 2 = 0 + +##Question 3# +a=1 +l=[1] +for i in range(10): + b=(1/2)*(a+(2/a)) + l+=[b**2-2] + a=b +i=0 +while 1<2: + if l[i]<0.00002 + print(i) + break + i+=1 +# On cherche a encadrer |Un**2 -2| +#Sachant que la condition d'arrêt de départ est : +#|Un-sqrt(2)|<10**-5 +#Or x->sqrt(x) est 1/2 lispsiptienne => |f(y)-f(x)|<1/2 |x-y| On pose x=Un**2 et y=2=(sqrt(2))**2 +#Ainsi, on a |Un -sqrt(2)|<1/2|Un**2-2| +#Or on souhaite avoir |Un -sqrt(2)|<10**-5. Une proposition plus forte consiste à dire: +# |Un-sqrt(2)|<1/2|Un**2-2|<10**-5 +#<=> 2*|Un-sqrt(2)|<|Un**2-2|<2*10**-5 +#D'ou la condition d'arrêt : |Un**2-2|<2*10**-5 + + + diff --git a/TP3/main.py b/TP3/main.py index f730e8e..ccba49e 100644 --- a/TP3/main.py +++ b/TP3/main.py @@ -168,4 +168,5 @@ def hauteur(n): if c>4999 and c%5000==0 and not input("continuer ? (oui/non) >").lower().startswith('o'): break print(N) - return c \ No newline at end of file + return c + diff --git a/TP3_bonus/main.py b/TP3_bonus/main.py index c7972e2..66d6201 100644 --- a/TP3_bonus/main.py +++ b/TP3_bonus/main.py @@ -47,6 +47,39 @@ import time def verification(m):# m=1000000 -> 60 sec start = time.time() - for c in range(2, m+1): + for c in range(0, m+1, ): tempsdarret(c) return time.time() - start + +# c) + +# Question 4 +# a) + + +def altitudemax(borne): + res = {"c":0, "altitude":0} + for c in range(3, borne+1, 4): + current = altitude(c) + if current > res["altitude"]: + res.update({"c":c, "altitude":current}) + return res + + +def tempsdarretmax(borne): # {'c': 665215, 'temps': 354} + res = {"c": 0, "temps": 0} + for c in range(3, borne+1, 4): + current = tempsdarret(c) + if current > res["temps"]: + res.update({"c": c, "temps": current}) + return res + +def tempsdarretrecord(borne): + res = {"c": 0, "temps": 0} + L=[] + for c in range(2, borne+1): + current = tempsdarret(c) + if current > res["temps"]: + res.update({"c": c, "temps": current}) + L.append({"c": c, "temps": current}) + return L \ No newline at end of file