Flowchart Version of Fibonacci



f(N) = g(N,0,1,0);

g(N,K,F,G) Þ K < N? h(N,K,F,G): F;

  h(N,K,F,G) = i(N,K,F,G,F);

  i(N,K,F,G,temp) = j(N,K,F+G,G,temp);

  j(N,K,F,G,temp) = K(N,K,F,temp,temp);

  K(N,K,F,G,temp) = g(N,K+1,F,G);

f(4) ==> g(4,2,1,1)

     ==> g(4,3,2,1)

     ==> g(4,4,3,2)

     ==> 3

 

f(x,y) = x == 0? y: g(x,y);

g(x,y) = x > y? k(x,y): h(x,y);

h(x,y) = k(y,x);

k(x,y) = f(x%y,y);

 

GCD algorithm Euclid

 

To Next Slide To Previous Slide To Contents