Factorial: Difference between revisions
Content added Content deleted
(Replace println() with print(); replace output "syntaxhighlight" tag with "pre" tag) |
WillBAnders (talk | contribs) |
||
Line 8,598:
===Iterative===
Standard iterative solution using a <code>for</code> loop:
* <code>range(2,
<syntaxhighlight lang="scala">
Line 8,613:
===Recursive===
Standard recursive solution using a pattern matching approach:
* <code>match</code> without arguments is a ''conditional match'', which works like <code>if/else</code> chains.
* Rhovas doesn't perform tail-call optimization yet, hence why this solution isn't tail recursive.
|