Skip to content

Instantly share code, notes, and snippets.

@carlogilmar
Created November 29, 2017 05:16
Show Gist options
  • Save carlogilmar/4e64770691a9f37aadbb276080ab77ab to your computer and use it in GitHub Desktop.
Save carlogilmar/4e64770691a9f37aadbb276080ab77ab to your computer and use it in GitHub Desktop.
Second Fibonacci Solution
/*Segunda Versión*/
var fibMemo: [UInt:UInt] = [0: 0, 1: 1]
func fib2(n:UInt)-> UInt{
if let result = fibMemo[n] {
return result
} else {
fibMemo[n] = fib2(n: n-1) + fib2(n: n-2)
}
return fibMemo[n]!
}
fib2(n: 20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment