Numerical integration by Euler's method

Parameters

m = 0.1;    (* mass (Kg) *)
s = 1.0;    (* spring constant (N/m) *)
dt=0.01;    (* time step (sec) *)
tmax = 10;  (* Total integration time (sec) *)

Function definition of force

Force[x_]:= -s*x;

Initialization

x0 = 0;
v0 = 1;
e0=0.5(m*v0^2 + s*x0^2); (* total initial energy *)
xlist={{0,x0}};  (* initialize output list *)
nsteps=tmax/dt;  (* number of integration steps *)

Integration

x=x0; (* variables *)
v=v0;
t=0;

(* Integrate by Euler's method *)
Do [ (* for n = 1 to nsteps *)
    t=n*dt;
    a = Force[x]/m;
    v=v+a*dt //N;
    x=x+v*dt //N;
    xlist = Append[xlist,{t,x}];
    ,{n,1,nsteps}]; (* end Do *) 
    	(*note: //N forces numerical evaluation *)

Results

Print["Calculated Period (s): ",2Pi/Sqrt[s/m]]
ListPlot[xlist]

(* final energy. Is it conserved? *)
e1=0.5(m*v*v+s*x*x);
Print["Initial energy: ",e0]
Print["Final energy: ",e1]