TÌM UCLN & BCNN CỦA 2 SỐ
#include <stdio.h>
#include<conio.h>
unsigned USCLN (unsigned n, unsigned m)
{
while (n != 0 && m != 0)
if (n>m)
n -= m;
else
m -= n;
if (n == 0)
return m;
else
Trang 2return n;
}
unsigned BSCNN (unsigned n, unsigned m)
{
return n * m / USCLN(n, m);
}
void main()
{
unsigned n, m;
printf("\nNhap hai vao so nguyen duong : ");
scanf("%u%u", &n, &m);
printf("\nUSCLN cua %u va %u = %u", n, m, USCLN(n,m)); printf("\nBSCNN cua %u va %u = %u", n, m, BSCNN(n,m));
Trang 3getch(); }