aboutsummaryrefslogtreecommitdiff
path: root/sample/recursive_functions/gcd.in
blob: 5a57d8d3bf157151c697f60c11f96cda695e3d57 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Greatest common divisor
//
//def gcd(a: Int, b: Int): Int =
//  if (b==0) a else gcd(b, a%b)


// Rule
gcd(ret, int a) >< (int b)
| b==0 => ret ~ a
| _ => gcd(ret, b) ~ a%b;

// Net
gcd(r, 14) ~ 21;
r; // it should be 7