[Solved] Part 2: Compute the Greatest Common Factor Solution

$25

File Name: Part_2:_Compute_the_Greatest_Common_Factor_Solution.zip
File Size: 480.42 KB

SKU: [Solved] Part 2: Compute the Greatest Common Factor Solution Category: Tag:
5/5 - (1 vote)

Write a program that computes the GCF (Greatest Common Factor) of two positive whole numbers entered by the user. For example the GCF of 24 and 18 is 6. The program will prompt the user for entering two positive whole numbers and will then return their GCF. The user may terminate the program by entering -1 for the first number. The program should provide a Tecursive function to compute GCF.

Test the above for at least 4 pairs of values. Mathematical Calculation: GCF of two whole numbers can be calculated mathematically via repeated division. For example, GCF of 16 and 26 can be found as below

1. Divide 16 into 26. The remainder is 10.

2. Divide 10 (the remainder in the last step) into 16 (the divisor in the last step). The remainder is 6.

3. Divide 6 (the remainder in the last step) into 10 (the divisor in the last step). The remainder is 4.

4. Divide 4 (the remainder in the last step) into 6 (the divisor in the last step). The remainder is 2.

5. Divide 2 (the remainder in the last step) into 4 (the divisor in the last step). The remainder is 0. Hence GCF is 2

Note: You are to provide a recursive function to implement the above algorithm.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] Part 2: Compute the Greatest Common Factor Solution
$25