Skip to content

Commit 9588803

Browse files
committed
gcd function
1 parent 09688ae commit 9588803

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

prog.8.5.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* Function to find the greatest common divisor
2+
of two nonnegative integer values */
3+
4+
#include <stdio.h>
5+
6+
void gcd (int u, int v)
7+
{
8+
int temp;
9+
10+
printf ("The gcd of %i and %i is ", u, v);
11+
12+
while ( v != 0 ) {
13+
temp = u % v;
14+
u = v;
15+
v = temp;
16+
}
17+
18+
printf ("%i\n", u);
19+
}
20+
21+
int main (void)
22+
{
23+
gcd (150, 35);
24+
gcd (1026, 405);
25+
gcd (83, 240);
26+
27+
return 0;
28+
}

0 commit comments

Comments
 (0)