/trunk/Examples/ocaml/argout_ref/example.c
C | 19 lines | 15 code | 2 blank | 2 comment | 1 complexity | c70f6a122c6778d65541b8e6028684e1 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
- /* 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;
- }