Question: to be solved in python Write a power function which takes in a value ' a ', ' b ' and ' c ' as

 to be solved in python Write a power function which takes

to be solved in python

Write a power function which takes in a value ' a ', ' b ' and ' c ' as inputs and returns ab as the output. However, unlike the regular power function, this function should recursively calculate the value of aby using the following reccurence relation: ab=(a(b/c))c - Alternatively, f(a,b)=f(a,b/c)f(a,b/c)f(a,b/c)c times i.e, First calculate a(b/c), store this in a variable, and use a loop to multiply it with itself c times. f(a,b/c) can be calulated by using this function recursively. (When c=2, this is known as binary exponentiation. It is used to save time on computing ab and can be much quicker that computing it through loop for larger numbers.) *It is given that b is a power of c. NUTE: Only correct submissions with proper implementation of quick exponentiation will be awarded marks. Using the inbuilt power function will result in a correct submission but it will not be graded. Input Format The first line contains three space separated integers, a,b and c. Constraints

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!