Question: Exponentiation and GCD WRITE A C++ PROGRAM Provide an iterative function named integerPower( base, exponent ) that returns the value of base exponent and an

Exponentiation and GCD

WRITE A C++ PROGRAM

Provide an iterative function named integerPower( base, exponent ) that returns the value of baseexponent and an iterative method named gcd( number1, number2 ) that returns the greatest common divisor of the numbers, number1 and number2. You may use Euclid's Algorithm to find the gcd.

Example result for GCD function: gcd(1543416,144) should return the value of 24.

For example: integerPower(3,4) calculates 34 ( or 3 * 3 * 3 * 3 ) = 81. Assume that the exponent parameter is a positive, nonzero integer; the base should be assumed to be any integer. Use a for loop or a while loop ( your choice ) as the control structure of the calculation.

If you want the extra challenge, look up the concept of exponentiation by squaring and try this method (1 point extra credit)!

Incorporate these functions into a program that prompts the user to enter a base, and exponent (for integerPower), also prompts the user for number1 and number2 (for gcd); then outputting the results.

Do not use the cmath library functions.

thanks alot for the help guys

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!