Guyz anyone can please answer how to find gcd using middle school method | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Guyz anyone can please answer how to find gcd using middle school method

3rd Apr 2017, 2:33 PM
Sandesh Virat
Sandesh Virat - avatar
2 Answers
+ 9
Which language? In general: You define two variables for which you want to find out what the gcd is. Then use the mod operator in a loop up to the minimal value of your two variables which checks if both of your variables mod the increment is 0. Store the increment if this is true for both variables. The last stored increment is your gcd then.
3rd Apr 2017, 4:43 PM
Tashi N
Tashi N - avatar
+ 1
tq tashi
7th Apr 2017, 2:38 AM
Sandesh Virat
Sandesh Virat - avatar