Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Cho hai số nguyên dương a và b, hãy tìm ước chung lớn nhất của hai giá trị này
- // cho 2 so nguyen duong a va b hay tim uoc chung lon nhat 2 so
- // Khai bao thu vien
- #include<stdio.h>
- #include<conio.h>
- int UCLN(int a,int b);
- void main()
- {
- int a,b;
- scanf("%d%d",&a,&b);
- printf("%d",UCLN(a,b));
- }
- int UCLN(int a,int b)
- {
- while(a!=b)
- {
- if(a>b)
- {
- a=a-b;
- }
- else
- {
- b=b-a;
- }
- }
- return a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement