fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int a, b, c;
  6. c = 1;
  7. printf("Enter a: ");
  8. scanf("%d", &a);
  9.  
  10. printf("Enter b: ");
  11. scanf("%d", &b);
  12. if(a > b, a % b == 0)
  13. {
  14. printf("GCD is %d", a);
  15. }
  16.  
  17.  
  18. while(c!=0, c > 0)
  19. {
  20. if(b <= a)
  21. {
  22. c = a - b;
  23. a = b;
  24. b = c;
  25. //printf(" a=%d ,b=%d ,c=%d\n", a, b, c);
  26. //printf("Press Enter to Continue"); //those 3 lines are for testing purpose only
  27. //while( getchar() != '\n' );
  28. }
  29. else
  30. {
  31. c = b - a;
  32. a = b;
  33. b = c;
  34. //printf(" a=%d ,b=%d ,c=%d\n", a, b, c);
  35. //printf("Press Enter to Continue"); //those 3 lines are for testing purpose only
  36. //while( getchar() != '\n' );
  37. }
  38. //printf("Press Enter to Continue");
  39. //while( getchar() != '\n' );
  40. }
  41. printf("GCD is %d\n", a);
  42. }
Success #stdin #stdout 0s 5408KB
stdin
7982347897
38472
stdout
Enter a: Enter b: GCD is 1