白駿-1150異項係数1-SWIFT


100準11050二項係数1
質問:https://www.acmicpc.net/problem/11050
Code :
let input = readLine()!.split(separator: " ").map{Int($0)!}
print(fac(input[0]) / (fac(input[0]-input[1]) * fac(input[1])))

func fac(_ x: Int) -> Int{
    if x <= 1{
        return 1
    }
    
    return x * fac(x-1)
}