问题:
求两个数的最小公倍数
#include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) { int m, n, b; int temp, k; int lcw; scanf("%d%d", &m, &n); k = m*n; if(m<n) { temp = m; m = n; n = temp; } b = m%n; while(b) { m = n; n = b; b = m%n; } lcw = k/n;//依照公式: 最小公倍数=两数乘积/最大公约数 printf("%d\n", lcw); return 0; } /* 45 63 315 4 5 20 */
原文地址:http://blog.csdn.net/orangeisnotapple/article/details/44787451