import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 10, 20, 30)
print (x)
y = np.sin(x)
plt.plot(x, y, c="blue", ls="--", lw=1, alpha=0.5)
plt.scatter(x, y, c="red", marker="+")
plt.show()
#Q3
def syracuse(n):
if n%2 == 0:
return(n/2)
else:
return(3*n+1)
Nmax = 100
x = np.linspace(0, Nmax, Nmax+1)
y = np.zeros(np.shape(x))
print(x)
u = int(input("Quelle est la valeur de u0 ?"))
y[0] = u
for i in range(1,Nmax+1):
y[i] = syracuse(u)
print(y)
plt.scatter(x,y)
plt.show()
To embed this project on your website, copy the following code and paste it into your website's HTML: