Skip to content

Commit 7030898

Browse files
Merge pull request #107 from ikaliuzh/patch-1
Update factorials.jl
2 parents 1efe1f6 + 864d358 commit 7030898

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/factorials.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ function partialderangement(n::Integer, k::Integer)
7171
end
7272

7373
# Hyperfactorial
74-
hyperfactorial(n::Integer) = prod(i->i^i, BigInt(2):n)
74+
hyperfactorial(n::Integer) = n==0 ? BigInt(1) : prod(i->i^i, BigInt(1):n)
75+
7576

7677
function multifactorial(n::Integer, m::Integer)
7778
if n < 0

test/factorials.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
# hyperfactorial
2424
@test hyperfactorial(8) == parse(BigInt,"55696437941726556979200000")
25+
@test hyperfactorial(0) == parse(BigInt,"1")
26+
@test hyperfactorial(1) == parse(BigInt,"1")
27+
@test hyperfactorial(2) == parse(BigInt,"4")
2528

2629
# multifactorial
2730
@test multifactorial(40,2) == doublefactorial(40)

0 commit comments

Comments
 (0)