chap mathematical preliminaries /iterative fibonacci generator static long fibi(int /fibr( is the largest value that fits in long assert ( &( < " out of range"long currprevpastif (( = |( = )return curr prev /curr holds current fib value for (int = <=ni++/compute next value past prev/past holds fibi( - prev curr/prev holds fibi( - curr past prev/curr now holds fibi(ireturn currfunction fibi executes the for loop times (awhich version is easier to understandwhy(bexplain why fibr is so much slower than fibi write recursive function to solve generalization of the towers of hanoi problem where each ring may begin on any pole so long as no ring sits on top of smaller ring consider the following functionstatic void foo (double valif (val ! foo(val/ )this function makes progress towards the base case on every recursive call in theory (that isif double variables acted like true real numbers)would this function ever terminate for input val nonzero numberin practice (an actual computer implementation)will it terminate write function to print all of the permutations for the elements of an array containing distinct integer values write recursive algorithm to print all of the subsets for the set of the first positive integers the largest common factor (lcffor two positive integers and is the largest integer that divides both and evenly lcf(nmis at least oneand at most massuming that > over two thousand years agoeuclid provided an efficient algorithm based on the observation thatwhen mod lcf(nmgcd(mn mod muse this fact to write two algorithms to find lcf for two positive integers the first version should compute the value iteratively the second version should compute the value using recursion