![]() ![]() Find minimum of the two numbers and store it in the variable min i.e., min=10. Now, print gcd as 3.Ĭonsider the two numbers are n1=10 and n2=15. ![]() Now, check the while loop condition again, this time remainder = 0, therefore come out of the loop and store the value of the denominator in gcd i.e., gcd = 3. Now, assign the value of the denominator to the numerator and the value of the remainder to the numerator i.e., numerator=12 and denominator=3 then calculate the remainder of the two variables i.e., remainder = 12%3 = 0. Now, enter the while loop and check if the remainder value is ‘0’ or not. Divide the numerator by the denominator and store the value in the remainder variable i.e., remainder = 15%12 = 3. When the value of the remainder variable becomes ‘0’ come out of the loop and store the value of the denominator in the gcd variable.Ĭonsider, the two numbers 12 and 15, first find the greater of the two numbers and store the greater in the numerator and smaller in the denominator i.e., numerator=15 and denominator=12. Inside the while loop keep on dividing the numerator by denominator and store the value in the remainder variable.Ĥ. Run the while loop until the remainder becomes ‘0’. Store the greater number in the variable numerator and the smaller number in the variable denominator.ģ. Take the two numbers num1 and num2 as input.Ģ.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |