Skip to content

Commit

Permalink
Create gcd of 2 numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
theroshanantony authored Oct 15, 2020
1 parent 444253b commit d6f5587
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions gcd of 2 numbers
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>
int main()
{
int n1, n2, i, gcd;

printf("Enter two integers: ");
scanf("%d %d", &n1, &n2);

for(i=1; i <= n1 && i <= n2; ++i)
{
// Checks if i is factor of both integers
if(n1%i==0 && n2%i==0)
gcd = i;
}

printf("G.C.D of %d and %d is %d", n1, n2, gcd);

return 0;
}

0 comments on commit d6f5587

Please sign in to comment.