Added comments
This commit is contained in:
parent
6dfc92e3dc
commit
fc59dd3913
@ -9,14 +9,14 @@
|
|||||||
|
|
||||||
int gcd (int p, int q)
|
int gcd (int p, int q)
|
||||||
{
|
{
|
||||||
int r,t;
|
int r;
|
||||||
while (q > 0)
|
while (q > 0) /* Loops until the remainder is 0 */
|
||||||
{
|
{
|
||||||
r = p%q;
|
r = p%q; /* Calculate remainder */
|
||||||
p=q;
|
p=q; /* Storing the value of q in p */
|
||||||
q=r;
|
q=r; /* Setting q to the value of the remainder to calculate new remainder in the next iteration */
|
||||||
}
|
}
|
||||||
return p;
|
return p; /* Returning p after the loop finishes */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user