作业帮 > 数学 > 作业

develop a program to calculater the least common multiple of

来源:学生作业帮 编辑:作业帮 分类:数学作业 时间:2024/05/28 14:38:51
develop a program to calculater the least common multiple of two numbers input from the keyboard
#include<stdio.h>  
void main()   //辗转相除法求最大公约数,然后最小公倍数=a*b/最大公倍数 
{   
   int m, n, a, b, t, c;  
   printf("Input two integer numbers:\n");  
   scanf("%d%d", &a, &b);  
   m=a;   n=b;  
   while(b!=0)  /* 余数不为0,继续相除,直到余数为0 */   
   { c=a%b; 
   a=b;  
   b=c;}  
   

   printf("The least common multiple:%d\n", m*n/a);  
}