Created
November 4, 2014 04:49
-
-
Save TrevorMcCormick/ea38fa11340d705098e7 to your computer and use it in GitHub Desktop.
Finds greatest common divisor of two nonnegative integer values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Program to find the greatest common divisor of two nonnegative integer values | |
#include <stdio.h> | |
int main (void) | |
{ | |
int u, v, temp; | |
printf ("Please type in two nonnegative integers.\n"); | |
scanf ("%i%i", &u, &v); | |
while ( v != 0 ) | |
{ | |
temp = u % v; | |
u = v; | |
v = temp; | |
} | |
printf ("Their greatest common divisor is %i\n", u); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment