logic for finding hcf in java
Answers
Answered by
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
Accountancy,
7 months ago
Accountancy,
7 months ago
Science,
1 year ago
Geography,
1 year ago
Biology,
1 year ago
Math,
1 year ago