Factorial: Difference between revisions

Add factorial for {{RacketScript}} http://www.racketscript.org/#example/factorial https://github.com/racketscript/racketscript
(Add factorial for {{RacketScript}} http://www.racketscript.org/#example/factorial https://github.com/racketscript/racketscript)
Line 8,181:
<syntaxhighlight lang="racket">(define (factorial n)
(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}}==
41

edits