diff options
Diffstat (limited to 'test/files/pos/cours2a.scala')
-rw-r--r-- | test/files/pos/cours2a.scala | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/files/pos/cours2a.scala b/test/files/pos/cours2a.scala new file mode 100644 index 0000000000..b888b88a96 --- /dev/null +++ b/test/files/pos/cours2a.scala @@ -0,0 +1,16 @@ +module m1 { + def factorial(n: Int): Int = + if (n == 0) 1 + else n * factorial(n-1); +} + +module m2 { + + def factorial(n: Int): Int = { + def factIter(n: Int, acc: Int): Int = { + if (n == 0) acc + else factIter(n - 1, acc * n) + } + factIter(n, 1) + } +} |