summaryrefslogtreecommitdiff
path: root/Examples/ocaml/argout_ref/example.c
blob: 6f095cddb8e3739fffcfff240613b2328184ca9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* File : example.c */

/* Compute the greatest common divisor of positive integers */
int gcd(int x, int y) {
  int g;
  g = y;
  while (x > 0) {
    g = x;
    x = y % x;
    y = g;
  }
  return g;
}

extern "C" void factor( int &x, int &y ) {
    int gcd_xy = gcd( x,y );
    x /= gcd_xy;
    y /= gcd_xy;
}