Question: Write a function called FindPower that takes 2 scalars, base and exponent, and produces a scalar called result. The function finds the value of the

 Write a function called FindPower that takes 2 scalars, base andexponent, and produces a scalar called result. The function finds the valueof the base raised to the power of the exponent. Inputs: -

Write a function called FindPower that takes 2 scalars, base and exponent, and produces a scalar called result. The function finds the value of the base raised to the power of the exponent. Inputs: - base (numeric scalar): the base value of the power calculation - exponent (numeric scalar): the exponent value of the power calculation Outputs: - result (numeric scalar): the value of base raised to the power of exponent The output argument result is a (numeric) scalar. Hint: use a for loop to multiply the base value by itself exponent times. For example: For the given inputs: base =2; exponent =5 On calling FindPower: result = FindPower(base, exponent); produces result =32 In result the value of base raised to the power of exponent is shown. Complete the function FindPower to produce a scalar called nearestSquare. nearestSquare is the square of the integer that is closest to the result value. Inputs: - base (numeric scalar): the base value of the power calculation - exponent (numeric scalar): the exponent value of the power calculation Outputs: - result (numeric scalar): the value of base raised to the power of exponent - nearestsquare (numeric scalar): the square of the integer that is closest to result Hint: use a while loop to go through the outMultiples array and check if the sum of the digits is odd using the sum() and mod() functions. For example: For the given inputs: base =2; exponent =5 ouput nearestSquare =25 The function FindPower takes in a base of 2 and an exponent of 5 , and produces a result of 32 ( 2 raised to the power of 5). It then finds the nearestsquare of the integer that is closest to result, which is 25 (5 raised to the power of 5 ). NOTE that 36 (6 raised to the power of 6 ) is closer to 32 rather than 25 . That being said, we are looking for the nearest sqaure value that is eaither equal to the P1 result or is less than P 1. 12345function[result,nearestSquare]=FindPower(base,exponent)%Codeforresult%Nameend Code to call your function? Assessment

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!