Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

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  result = recSine(x,tol)
if x > tol
x = recSine(x/3,tol);
verdiresult = 3*x-4*x^3;
else
    verdiresult = 3*(x/3)-4*(x/3)^3;
end
end

g)

Code Block
function kallepaaMult()
tol = 0.01;
ans result = recMult(1,tol)
end
function  verdi = recMult(n,tol)
if (1+1/n^2) < 1+ tol
    verdiresult =  1;
else
    verdiresult = (1+1/n^2)*recMult(n+1,tol);
    display(verdi	disp(result)
end
end