Created
February 9, 2020 16:06
-
-
Save keisukeYamagishi/a89981ed3339353015f5b7f962e1942e to your computer and use it in GitHub Desktop.
順列の計算式を記録
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
def pattern (items, pattern) | |
(fact 4) / (fact (items.count - pattern)) | |
end | |
#階乗 | |
def fact(n, a=1) | |
return a if n == 0 | |
fact(n-1, n*a) | |
end | |
p pattern [1,2,3,4], 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment