Special factorials: Difference between revisions
Add bruijn
m (→{{header|Wren}}: Minor tidy) |
(Add bruijn) |
||
Line 318:
rf(3628800) = 10
rf(119) = null</pre>
=={{header|Bruijn}}==
Implementation for numbers encoded in balanced ternary using Mixfix syntax defined in the Math module:
<syntaxhighlight lang="bruijn">
:import std/Combinator .
:import std/Math .
factorial [∏ (+1) → 0 | [0]]
superfactorial [∏ (+1) → 0 | factorial]
hyperfactorial [∏ (+1) → 0 | [0 ** 0]]
alternating-factorial y [[(0 =? (+1)) 0 ((factorial 0) - (1 --0))]]
exponential-factorial y [[(0 =? (+1)) 0 (0 ** (1 --0))]]
:test ((factorial (+4)) =? (+24)) ([[1]])
:test ((superfactorial (+4)) =? (+288)) ([[1]])
:test ((hyperfactorial (+4)) =? (+27648)) ([[1]])
:test ((alternating-factorial (+3)) =? (+5)) ([[1]])
:test ((exponential-factorial (+4)) =? (+262144)) ([[1]])
</syntaxhighlight>
=={{header|C}}==
|