/******************************************
 This Program gets two positive integers
 from the user and computes their GCD.
 ******************************************/
#include <stdio.h>

int main() {
  int a;
  int b;

  // Read in a
  printf("Enter a positive integer: ");
  fflush(stdout);
  int check = scanf(" %i", &a);
  while(check < 1 || a <= 0) {
    printf("I said *positive*, try again: ");
    fflush(stdout);
    check = scanf(" %i", &a);
  }

  // Read in b
  printf("Enter a positive integer: ");
  fflush(stdout);
  check = scanf(" %i", &b);
  while(check < 1 || b <= 0) {
    printf("I said *positive*, try again: ");
    fflush(stdout);
    check = scanf(" %i", &b);
  }

  // Compute gcd
  while(b != 0) {
    int r = a % b;
    a = b;
    b = r;
  }

  // Write out gcd
  printf("The gcd is %i\n", a);

  return 0;
}