Created
January 2, 2017 10:56
-
-
Save nbyouri/ca21ae1648ff70c1c349d5e5b8fcea34 to your computer and use it in GitHub Desktop.
Small Julia utilities for counting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# C(n,r) | |
function C(n::Int, r::Int) | |
return (factorial(n)) / (factorial(r)*factorial(n - r)) | |
end | |
# P(n,r) | |
function P(n::Int, r::Int) | |
return (factorial(n) / factorial(n -r)) | |
end | |
# Sum of a function in a j .. n range | |
function ∑(j::Int, n::Int, f::Function) | |
ans = 0 | |
for i = j : n | |
ans += f(n, i) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment