Created
November 25, 2018 07:12
-
-
Save rkhang7/0a962d4ae4d8bcd1a241f7acd1ca40f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // tim UCLN cua a,b. | |
| #include <stdio.h> | |
| #include <conio.h> | |
| int main() | |
| { | |
| int a,b; | |
| printf("a=");scanf("%d",&a); | |
| printf("b=");scanf("%d",&b); | |
| if(a>b) | |
| { | |
| for(int i=a;i>=1;i--) | |
| { | |
| if(a%i==0 && b%i==0) | |
| { | |
| printf("UCLN cua %d va %d la %d",a,b,i); | |
| break; | |
| } | |
| } | |
| } | |
| if(a<b) | |
| { | |
| for(int j=b;j>=1;j--) | |
| { | |
| if(a%j==0 && b%j==0) | |
| { | |
| printf("UCLN cua %d va %d la %d",a,b,j); | |
| break; | |
| } | |
| } | |
| } | |
| if(a==b) printf("UCLN cua %d va %d la %d",a,b,a); | |
| getch(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment