faculty
[cc1516.git] / examples / old / Markus / recursion.spl
1 // Greatest common divisor,
2 // "The granddaddy of all algorithms, because it is the oldest nontrivial
3 // algorithm that has survived to the present day." -- Don Knuth
4
5 // This one only works for positive n, m
6 gcd(m, n)
7 {
8 if( n < m )
9 return gcd(n, m);
10 else if( n == m )
11 return n;
12 else // n > m
13 return gcd(m, n - m);
14 }
15 main() {return;}