/trunk/Examples/octave/contract/example.c

# · C · 23 lines · 15 code · 5 blank · 3 comment · 2 complexity · b4f27c8b431dd413d130768258723d91 MD5 · raw file

  1. /* File : example.c */
  2. /* A global variable */
  3. double Foo = 3.0;
  4. /* Compute the greatest common divisor of positive integers */
  5. int gcd(int x, int y) {
  6. int g;
  7. g = y;
  8. while (x > 0) {
  9. g = x;
  10. x = y % x;
  11. y = g;
  12. }
  13. return g;
  14. }
  15. int fact(int n) {
  16. if (n <= 0) return 1;
  17. return n*fact(n-1);
  18. }