MIPI_BaseC_WebinarFRTK/07_Lecture07/13_gcd_p37.c

22 lines
301 B
C
Raw Permalink Normal View History

2024-11-13 09:22:28 +03:00
#include <stdio.h>
int gcd ( int n, int m )
{
if(n == m)
return n ;
if (n < m)
return gcd(n,m - n );
return gcd(n - m,m );
}
int main()
{
int a,b;
printf("a=");
scanf("%d",&a);
printf("b=");
scanf("%d",&b);
printf("GCD=%d",gcd(a,b));
return 0;
}