YAPC::EU 2018 Glasgow Update!
This commit is contained in:
parent
22f33d4004
commit
4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions
12
Task/Catalan-numbers/Swift/catalan-numbers.swift
Normal file
12
Task/Catalan-numbers/Swift/catalan-numbers.swift
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
func catalan(_ n: Int) -> Int {
|
||||
switch n {
|
||||
case 0:
|
||||
return 1
|
||||
case _:
|
||||
return catalan(n - 1) * 2 * (2 * n - 1) / (n + 1)
|
||||
}
|
||||
}
|
||||
|
||||
for i in 1..<16 {
|
||||
print("catalan(\(i)) => \(catalan(i))")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue