fork download
  1. #include <stdio.h>
  2. int gcd(int a, int b) {
  3. if (b == 0) {
  4. return a;
  5. }
  6. return gcd(b, a % b);
  7. }
  8. int main() {
  9. int num1, num2;
  10. printf("Enter two positive integers: ");
  11. scanf("%d %d", &num1, &num2);
  12. printf("GCD of %d and %d = %d", num1, num2, gcd(num1, num2));
  13. return 0;
  14. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Enter two positive integers: GCD of 351328992 and 32766 = 6