Skip to content

Commit

Permalink
Merge 18e0bc1 into d44f1a0
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed Mar 17, 2017
2 parents d44f1a0 + 18e0bc1 commit a2750ed
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
julia 0.5
Compat 0.9.4
Compat 0.9.5
Polynomials
Iterators
2 changes: 1 addition & 1 deletion src/factorials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ factorial(n::Integer, k::Integer) = factorial(promote(n, k)...)
"The number of permutations of n with no fixed points (subfactorial)"
function derangement(sn::Integer)
n = BigInt(sn)
return num(factorial(n)*sum([(-1)^k//factorial(k) for k=0:n]))
return numerator(factorial(n)*sum([(-1)^k//factorial(k) for k=0:n]))
end
subfactorial(n::Integer) = derangement(n)

Expand Down
10 changes: 5 additions & 5 deletions src/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ export bellnum,
stirlings2

import Base: factorial, binomial

"Returns the n-th Bell number"
function bellnum(bn::Integer)
if bn < 0
throw(DomainError())
else
n = BigInt(bn)
end
list = Array(BigInt, div(n*(n+1), 2))
list = Vector{BigInt}(div(n*(n+1), 2))
list[1] = 1
for i = 2:n
beg = div(i*(i-1),2)
Expand Down Expand Up @@ -92,7 +92,7 @@ function stirlings1(n::Int, k::Int, signed::Bool=false)
if signed == true
return (-1)^(n - k) * stirlings1(n, k)
end

if n < 0
throw(DomainError())
elseif n == k == 0
Expand All @@ -110,7 +110,7 @@ function stirlings1(n::Int, k::Int, signed::Bool=false)
elseif k == n - 3
return binomial(n, 2) * binomial(n, 4)
end

return (n - 1) * stirlings1(n - 1, k) + stirlings1(n - 1, k - 1)
end

Expand All @@ -126,6 +126,6 @@ function stirlings2(n::Int, k::Int)
elseif k == 2
return 2^(n-1) - 1
end

return k * stirlings2(n - 1, k) + stirlings2(n - 1, k - 1)
end
6 changes: 3 additions & 3 deletions src/youngdiagrams.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Young diagrams, partitions of unity and characters of the symmetric group Sn #
################################################################################

typealias Partition Vector{Int}
typealias YoungDiagram Array{Int,2}
typealias SkewDiagram Tuple{Partition, Partition}
const Partition = Vector{Int}
const YoungDiagram = Array{Int,2}
const SkewDiagram = Tuple{Partition, Partition}

export Partition,
YoungDiagram, #represents shape of Young diagram
Expand Down

0 comments on commit a2750ed

Please sign in to comment.