Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BÀI 17:Nhập 2 số tự nhiên m,n rồi kiểm tra xem chúng có nguyên tố cùng nhau không
- #include <stdio.h>
- #include <conio.h>
- #include <iostream.h>
- int UCLN(unsigned int m, unsigned int n) {
- if(m==n)
- return m;
- else if(m>n)
- return UCLN(m-n,n);
- elsereturn UCLN(m,n-m);}
- void main() {
- clrscr();
- unsigned int m,n;
- cout<<"\n Nhap m = "; cin>>m;
- cout<<"\n Nhap n = "; cin>>n;
- if (UCLN(m,n) ==1)
- cout<<"\n "<<m<<" va "<<n<<" la hai so nguyen to cung nhau";if (UCLN(m,n) !=1)cout<<"\n "<<m<<" va "<<n<<" khong phai la hai so nguyen to cung nhau";
- getch();}
Advertisement
Add Comment
Please, Sign In to add comment