repositories
/
cc1516.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
working on presentation
[cc1516.git]
/
examples
/
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
}