Created
November 29, 2017 05:16
-
-
Save carlogilmar/4e64770691a9f37aadbb276080ab77ab to your computer and use it in GitHub Desktop.
Second Fibonacci Solution
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
/*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