Working commit.
This commit is contained in:
16
euclid.c
Normal file
16
euclid.c
Normal 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
19
main.c
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user