Working commit.

This commit is contained in:
2017-12-27 19:38:38 -06:00
parent 81541daefd
commit babc8606ac
2 changed files with 35 additions and 0 deletions

16
euclid.c Normal file
View File

@@ -0,0 +1,16 @@
#include <stdio.h>
#include <stdlib.h>
int euclid(int m, int n)
{
int remainder;
remainder = m % n;
while(remainder != 0) {
m = n;
n = remainder;
remainder = m % n;
}
return(n);
}

19
main.c Normal file
View File

@@ -0,0 +1,19 @@
#include <stdio.h>
#include <stdlib.h>
void main()
{
char str[100];
int m;
int n;
int answer;
printf("Enter an integer:");
fgets(str, 100, stdin);
m = atoi(str);
printf("Enter another integer:");
fgets(str, 100, stdin);
n = atoi(str);
answer = euclid(m, n);
printf("The greatest common divisor between these two integers is %d\n", answer);
}