...
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 result = recSine(x,tol)
if x > tol
x = recSine(x/3,tol);
result = 3*x-4*x^3;
else
result = 3*(x/3)-4*(x/3)^3;
end
end |
g)
Code Block |
---|
function result = recMult(n,tol)
if (1+1/n^2) < 1+ tol
result = 1;
else
result = (1+1/n^2)*recMult(n+1,tol);
disp(result)
end
end |