PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/trunk/Examples/ocaml/argout_ref/example.c

#
C | 19 lines | 15 code | 2 blank | 2 comment | 1 complexity | c70f6a122c6778d65541b8e6028684e1 MD5 | raw file
 1/* File : example.c */
 2
 3/* Compute the greatest common divisor of positive integers */
 4int gcd(int x, int y) {
 5  int g;
 6  g = y;
 7  while (x > 0) {
 8    g = x;
 9    x = y % x;
10    y = g;
11  }
12  return g;
13}
14
15extern "C" void factor( int &x, int &y ) {
16    int gcd_xy = gcd( x,y );
17    x /= gcd_xy;
18    y /= gcd_xy;
19}