3100. 最大公约数

Naive递归函数

时间限制:2000 ms

内存限制:256 MiB

题面

使用递归方法定义函数 GCDGCD 求两个整数的最大公约数。

//********** Specification of GCD **********
int GCD(int m,int n);
/* PreCondition:
m,n are two positive integers
PostCondition:
return Greatest Common Divisor of m and n
*/

只需按要求写出函数定义,并使用给定的测试程序测试你所定义函数的正确性。不要改动测试程序。测试正确后,将测试程序和函数定义一起提交。

/***************************************************************/
/*                                                             */
/*  DON'T MODIFY main function ANYWAY!                         */
/*                                                             */
/***************************************************************/
#include <stdio.h>

//********** Specification of GCD **********
int GCD(int m,int n)
/* PreCondition:
m,n are two positive integers
PostCondition:
return Greatest Common Divisor of m and n
*/
{
	//TODO: your function definition
}
/***************************************************************/
int main()
{
	int m,n;
	scanf("%d%d",&m,&n);
	//********** GCD is called here ********************
	printf("GCD(%d,%d)=%d\n",m,n,GCD(m,n));
	//**************************************************
	return 0;
}

样例

输入

2 3

输出

GCD(2,3)=1