Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 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