...
Code Block |
---|
function tower_of_hanoi (n, source , dest , temp ) if n > 0 tower_of_hanoi (n -1, source , temp , dest ); fprintf ('Flytt fra %i til %i\n', source , dest ); tower_of_hanoi (n -1, temp , dest , source ); end end |
f)
Code Block |
---|
function kallepaaSinus()
tol = 0.01;
x = 0.5;
ans = recSine(x,tol)
end
function verdi = recSine(x,tol)
if x > tol
x = recSine(x/3,tol);
verdi = 3*x-4*x^3;
else
verdi = 3*(x/3)-4*(x/3)^3;
end
end |