repl.it
@rschweizer/

Stage Nouveaux Programmes

Python

No description

fork
loading
Files
  • main.py
  • graphique.png
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from matplotlib.pyplot import *
from numpy import *


def rec(u):
  return u**2-3*u+1




def termsuit(u,a,b,n):
  for i in range (n):
    u=rec(u)
  return u


def fact(p):
  if p==0:
    return 1
  else:
    return p*fact(p-1)





def Syr(n,p):
  L=[n]
  for i in range (p):
    if L[i]%2==0:
      L.append(L[i]/2)
    else:
      L.append(3*L[i]+1)
  print (L)



def VolSyr(n):
  L=[n]
  i=0
  while L[i]!=1:
    if L[i]%2==0:
      L.append(L[i]/2)
    else:
      L.append(3*L[i]+1)
    i=i+1
  print(i+1)



def Euler(b,n):
  A=[i for i in arange(0,b+10**(-n),10**(-n))]
  B=[1]
  for i in range(b*(10**n)):
    B.append((1+10**(-n))*B[i])
  plot(A,B,"r-")
  axis([-0.1,b+10**(-n),-0.1,2**b])
  title ("Méthode d'Euler")
  grid()
  savefig ("graphique.png")
  return