[TP 3] Exo Bonus - Syracuse

This commit is contained in:
Suwako Moriya 2019-11-23 18:50:14 +01:00
parent 02c92aedeb
commit 501e22da33
Signed by: SuwakoMmh
GPG Key ID: A27482B806F13CD5

View File

@ -117,4 +117,26 @@ def binomes(n):
for j in range(i):
l.append(lastl.pop(0) + lastl[0])
lastl=l+ [0]
return(l)
return(l)
#Exercice bonus : Conjecture de Syracuse
def syracuse(n):
if n%2:
return 3*n + 1
return n/2
def NbrEtapes(n):
l=n
i=0
while l!=1:
l=syracuse(l)
i+=1
return i
def printNbrEtapes(n):
a=[NbrEtapes(i) for i in range(1, n+1)]
print(a)
return a
#Exercice bonus : Palindromes et nombres de Lychrel