//
//ViewController.m
//CocoTest_1
//
//Created by S u p e r m a n on 2017/3/14.
//Copyright © 2017年张浩. All rights reserved.
//
#import"ViewController.h"
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
printf("最大公约数%d",greatestCommonFactor(98,63));
}
intgreatestCommonFactor(intn,intm) {
//n始终要大于m
if(n
inttemp = n;
n = m;
m = temp;
}
if(n%m ==0) {//递归结束
returnm;
}else{
inttemp_n = m;
inttemp_m = n%m;
returngreatestCommonFactor(temp_n,temp_m);
}
}
@end