Question #265264

Write a C program to find common divisors between two numbers in a given pair.

Expert's answer

#include <stdio.h>

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  while (a && b) {
    a %= b;
    int c = a;
    a = b;
    b = c;
  }
  printf("GCD: %d\n", a + b);
  return 0;
}
LATEST TUTORIALS
APPROVED BY CLIENTS