We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9588803 commit 98db624Copy full SHA for 98db624
prog.8.6.c
@@ -0,0 +1,32 @@
1
+/* Function to find the greatest common divisor of two
2
+ nonnegative integer values and to return the result */
3
+
4
+#include <stdio.h>
5
6
+int gcd (int u, int v)
7
+{
8
+ int temp;
9
10
+ while ( v != 0 ) {
11
+ temp = u % v;
12
+ u = v;
13
+ v = temp;
14
+ }
15
16
+ return u;
17
+}
18
19
+int main (void)
20
21
+ int result;
22
23
+ result = gcd (150, 35);
24
+ printf ("The gcd of 150 and 35 is %i\n", result);
25
26
+ result = gcd (1026, 405);
27
+ printf ("The gcd of 1026 and 405 is %i\n", result);
28
29
+ printf ("The gcd of 83 and 240 is %i\n", gcd (83, 240));
30
31
+ return 0;
32
0 commit comments