Study guides

☆

Q: How do you draw a flowchart of HCF of two given numbers?

Write your answer...

Submit

Still have questions?

Continue Learning about Engineering

Algorithm: to find HCF of two nos a, b 1. Find larger of two and let it l, smaller = s 2. divide l by s and find qotient (q) & remainder(r) 3. if r is 0 then s is the hcf 4. put l=s, s=r and go to step 2 int a, b; int l,s,q,r; if (a>b) {l=a;s=b;} else {l=b;s=a;} do {q= l/s; r=l%s; if (r != 0) {l=s;s=r} } while (r != 0); hcf=s; /* this variable to be output or returned as a function value as per programmer's convenience */

for two positive integers: public static int gcd(int i1, int i2) { // using Euclid's algorithm int a=i1, b=i2, temp; while (b!=0) { temp=b; b=a%temp; a=temp; } return a; }

For the greatest common factor, you can use the following to your advantage. As an example, take the numbers 14 and 10 as input.The greatest common factor of 14 and 10 is the same as the greatest common factor of 10 and 4, where 4 has been obtained by subtracting 14 - 10 (or, faster, to avoid repeated subtraction, take the remainder of a division: 14 % 10).If you divide 10 % 4 (or subtract 4 twice, from 10), you get a remainder of 2, so the new set of numbers is 4 and 2.Next step: 4 % 2 = 0. Once you get a remainder of zero, the previous number is the answer - the number that you should return. In this case, the 2.For the least common multiple, use the property that (using a numeric example) 14 x 10 = 2 x 70 (14 and 10 are the two parameters, 2 and 70 are the greatest common factor and the least common multiple, respectively).For the greatest common factor, you can use the following to your advantage. As an example, take the numbers 14 and 10 as input.The greatest common factor of 14 and 10 is the same as the greatest common factor of 10 and 4, where 4 has been obtained by subtracting 14 - 10 (or, faster, to avoid repeated subtraction, take the remainder of a division: 14 % 10).If you divide 10 % 4 (or subtract 4 twice, from 10), you get a remainder of 2, so the new set of numbers is 4 and 2.Next step: 4 % 2 = 0. Once you get a remainder of zero, the previous number is the answer - the number that you should return. In this case, the 2.For the least common multiple, use the property that (using a numeric example) 14 x 10 = 2 x 70 (14 and 10 are the two parameters, 2 and 70 are the greatest common factor and the least common multiple, respectively).For the greatest common factor, you can use the following to your advantage. As an example, take the numbers 14 and 10 as input.The greatest common factor of 14 and 10 is the same as the greatest common factor of 10 and 4, where 4 has been obtained by subtracting 14 - 10 (or, faster, to avoid repeated subtraction, take the remainder of a division: 14 % 10).If you divide 10 % 4 (or subtract 4 twice, from 10), you get a remainder of 2, so the new set of numbers is 4 and 2.Next step: 4 % 2 = 0. Once you get a remainder of zero, the previous number is the answer - the number that you should return. In this case, the 2.For the least common multiple, use the property that (using a numeric example) 14 x 10 = 2 x 70 (14 and 10 are the two parameters, 2 and 70 are the greatest common factor and the least common multiple, respectively).For the greatest common factor, you can use the following to your advantage. As an example, take the numbers 14 and 10 as input.The greatest common factor of 14 and 10 is the same as the greatest common factor of 10 and 4, where 4 has been obtained by subtracting 14 - 10 (or, faster, to avoid repeated subtraction, take the remainder of a division: 14 % 10).If you divide 10 % 4 (or subtract 4 twice, from 10), you get a remainder of 2, so the new set of numbers is 4 and 2.Next step: 4 % 2 = 0. Once you get a remainder of zero, the previous number is the answer - the number that you should return. In this case, the 2.For the least common multiple, use the property that (using a numeric example) 14 x 10 = 2 x 70 (14 and 10 are the two parameters, 2 and 70 are the greatest common factor and the least common multiple, respectively).

Related questions

First you will need to pick out the two numbers. Then you can use your textbook and the instructions in order to draw out the flow chart.

sfafa

The HCF of the given two numbers is 40

The HCF of the given two numbers is 14

The HCF of the given numbers is 1

The HCF of the given two numbers is 8

The HCF of the given two numbers is 28

The HCF of the given numbers is 14

The HCF of the given three numbers is 7

The HCF of the given three numbers is 15

The HCF of the given two numbers is 6

The HCF of the given numbers is 237

People also asked