Special factorials: Difference between revisions

(Add bruijn)
 
Line 325:
<syntaxhighlight lang="bruijn">
:import std/Combinator .
:import std/List .
:import std/Math .
 
Line 333 ⟶ 334:
hyperfactorial [∏ (+1) → 0 | [0 ** 0]]
 
alternating-factorial y [[(0 =? (+1))0 0 ((factorial 0) - (1 --0))]]
 
exponential-factorial y [[(0 =? (+1))0 0 (0 ** (1 --0))]]
 
:test ((factorial (+4)) =? (+24)) ([[1]])
Line 342 ⟶ 343:
:test ((alternating-factorial (+3)) =? (+5)) ([[1]])
:test ((exponential-factorial (+4)) =? (+262144)) ([[1]])
 
invfac y [[[compare-case 1 (2 ++1 0) (-1) 0 (∏ (+0) → --1 | ++‣)]]] (+0)
 
:test ((invfac (+1)) =? (+0)) ([[1]])
:test ((invfac (+2)) =? (+2)) ([[1]])
:test ((invfac (+6)) =? (+3)) ([[1]])
:test ((invfac (+24)) =? (+4)) ([[1]])
:test ((invfac (+120)) =? (+5)) ([[1]])
:test ((invfac (+720)) =? (+6)) ([[1]])
:test ((invfac (+5040)) =? (+7)) ([[1]])
:test ((invfac (+40320)) =? (+8)) ([[1]])
:test ((invfac (+362880)) =? (+9)) ([[1]])
:test ((invfac (+3628800)) =? (+10)) ([[1]])
:test ((invfac (+119)) =? (-1)) ([[1]])
 
seq-a [((superfactorial 0) : ((hyperfactorial 0) : {}(alternating-factorial 0)))] <$> (iterate ++‣ (+0))
 
seq-b exponential-factorial <$> (iterate ++‣ (+0))
 
# return first 10/4 elements of both sequences
main [(take (+10) seq-a) : {}(take (+5) seq-b)]
</syntaxhighlight>
 
55

edits