fork download
  1. #include<stdio.h>
  2. #include<math.h>
  3. int d,x,y;
  4. int UCLN(int a,int b){
  5. if(b==0){
  6. d=a;
  7. x=1;
  8. y=0;
  9. }
  10. else{
  11. UCLN(b,a%b);
  12. int temp = x;
  13. x=y;
  14. y=temp-(a/b)*y ;
  15.  
  16. }
  17. }
  18. int main(){
  19. int a,b;
  20. printf("Nhap a:");
  21. scanf("%d",&a);
  22. printf("Nhap b:");
  23. scanf("%d",&b);
  24. UCLN(a,b);
  25. printf("UCLN(%d,%d) la: %d",a,b,d) ;
  26. printf("\nx=%d,y=%d",x,y);
  27. }
Success #stdin #stdout 0.01s 5476KB
stdin
Standard input is empty
stdout
Nhap a:Nhap b:UCLN(-750681616,32764) la: 4
x=3926,y=89951655