![]() ![]() Inside the loop, we check if i is a factor of two numbers, then set i as HCF, i.e., gcd i. Then, we find the minimum between the given two numbers and run the for loop from 1 to the minimum value. Printf("\nEnter your numbers below :- \n ") Įnter how many no. First, we take two numbers from the user and store them in variables num1 and num2. ![]() Printf("Enter how many no.s u want to find gcd : ") One writes: Here below is the source code of the C program to find HCF of N numbers using Arrays.The program is successfully compile and run(on Codeblocks) on the windows system and produce output below : That is, the greatest common divisor of 54 and 24. The numbers that these two lists share in common are the common divisors of 54 and 24: The function computes and returns the H.C.F. In the main () function, we read two integer numbers num1 and num2 from the user and called the calculateHCF () function, and printed the HCF of given numbers on the console screen. Thus the divisors of 54 are: 1, 2, 3, 6, 9, 18, 27, 54 The Highest Common Factor (HCF) of the numbers 24 36 12 Explanation: The findGcd () function is called with two integers stored in variables number1 and number2. The calculateHCF () function is a recursive function, which is used to find the Highest Common Factor of specified numbers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |