Factorial: Difference between revisions
Content added Content deleted
(Add factorial for {{RacketScript}} http://www.racketscript.org/#example/factorial https://github.com/racketscript/racketscript) |
(→{{header|RacketScript}}: remove) Tag: Manual revert |
||
Line 8,181: | Line 8,181: | ||
<syntaxhighlight lang="racket">(define (factorial n) |
<syntaxhighlight lang="racket">(define (factorial n) |
||
(for/product ([i (in-range 1 (+ n 1))]) i))</syntaxhighlight> |
(for/product ([i (in-range 1 (+ n 1))]) i))</syntaxhighlight> |
||
=={{header|RacketScript}}== |
|||
<syntaxhighlight lang="racket">#lang racket/base |
|||
(define (factorial n) |
|||
(let loop ([n n] |
|||
[a 1]) |
|||
(if (zero? n) |
|||
a |
|||
(loop (sub1 n) (* n a))))) |
|||
(displayln (factorial 6))</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
Console Log: |
|||
[log] "720" |
|||
</pre> |
|||
=={{header|Raku}}== |
=={{header|Raku}}== |