-
Notifications
You must be signed in to change notification settings - Fork 1
/
gcd.c
45 lines (38 loc) · 746 Bytes
/
gcd.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* File: gcd.c
* Author: Mudathir Lawal
* Email: mudathir.lawal@yahoo.com
* GitHub: github.com/mudathirlawal
* Last Edit: 22th September, 2018.
* Version: 1.1.0 EN
*
* Purpose: To find the greatest common divisor.
*
*/
#include <stdio.h>
//#define TRUE 1
//#define FALSE 0
//#define EXIT_SUCCESS 0
//#define EXIT_FAILURE -1
int gcd ( int, int );
int gcd ( int argA, int argB )
{
if ( argB == 0 )
{
int a = 36;
int b = 16;
printf ( "\n\tGCD ( %i, %i ) = %i\n\n", a, b, argA );
return argA;
}
else
{
int remainder = argA % argB;
return gcd ( argB, remainder );
}
}
int main ( void )
{
int argA = 36;
int argB = 16;
return gcd ( argA, argB );
}