Computer Science, asked by Anonymous, 11 months ago

logic for finding hcf in java

Answers

Answered by Sparshfan00
3

An H.C.F or Highest Common Factor, is the largest common factor of two or more values.

For example factors of 12 and 16 are:

12 → 1, 2, 3, 4, 6, 12

16 → 1, 2, 4, 8, 16

The common factors are 1, 2, 4 and the highest common factor is 4.

Algorithm

1. Define two variables - A, B

2. Set loop from 1 to max of A, B

3. Check if both are completely divided by same loop number, if yes, store it

4. Display the stored number is HCF

Similar questions