function [y,t]=Eulerexplicite(k,r,t0,tf,y0,N)
    nvec=[0:1:N]
    dt=(tf-t0)/N
    t=t0.*ones(1,N+1)+nvec.*(tf-t0)/N
    y=zeros(1,N+1)
    y(1)=y0
    for i=1:N
            y(i+1)=y(i)+dt*(-k*y(i) + r)
    end
endfunction
function [y,t]=Eulerimplicite(k,r,t0,tf,y0,N)
    nvec=[0:1:N]
    dt=(tf-t0)/N
    t=t0.*ones(1,N+1)+nvec.*(tf-t0)/N
    y=zeros(1,N+1)
    y(1)=y0
    for i=1:N
            y(i+1)=(y(i)+r*dt)/(1+k*dt)
    end
endfunction


