Question: I'm trying to write fast exponentiation method using russian peasant algorithm in tail recursion using the Ocaml. But I don't know which part of the

I'm trying to write fast exponentiation method using russian peasant algorithm in tail recursion using the Ocaml. But I don't know which part of the code is wrong...
let fastExp base power- let rec helper base power acc if base -0 then else if power = 0 then 1 (*/Note that this is the base case/*) else if (odd power) then helper base (power-1) (base * acc) (/Here, I have to try to make power gets close to the base case/*) (/Also, update the accumulator as how we want it/*) else let tmphelper base (power/2) (basexacc) in tmp*tmp (*/also trying to make power gets close to the base case b/c we ddn't w he key in the ine of code above is that casi /I think the key in the line of code above is that we are calling the helper function twice so that the accumulator can also be updated twice as mudh/*) in helper base power 1;; let fastExp base power- let rec helper base power acc if base -0 then else if power = 0 then 1 (*/Note that this is the base case/*) else if (odd power) then helper base (power-1) (base * acc) (/Here, I have to try to make power gets close to the base case/*) (/Also, update the accumulator as how we want it/*) else let tmphelper base (power/2) (basexacc) in tmp*tmp (*/also trying to make power gets close to the base case b/c we ddn't w he key in the ine of code above is that casi /I think the key in the line of code above is that we are calling the helper function twice so that the accumulator can also be updated twice as mudh/*) in helper base power 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
