###Memoization
Memoization
###Memoization
Memoization
Since Swift doesn't have the same sort of static function variables as Objective-C and other languages have, we have to consult this Stack Overflow question this Stack Overflow question to figure out how to achieve something similar.
Since Swift doesn't have the same sort of static function variables as Objective-C and other languages have, we have to consult this Stack Overflow question to figure out how to achieve something similar.
Since Swift doesn't have the same sort of static function variables as Objective-C and other languages have, we have to consult this Stack Overflow question to figure out how to achieve something similar.
###Memoization...
The difference between one addition operation and two addition operations may not be measurable. But by the 500th or 1000th or more iteration of your loop, the difference between one addition operation and 500 addition operations starts to become noticeable. (And this is minor addition to the time it takes... but when we do find the number, we have to then recalculate it inside your if
branch).
There is still a lot to work on for this problem, but I think this answer sets you down a very good path. Think about what this memoization is doing for us, and try to see where we can apply it in other places (especially as you work through Project Euler).
###Memoization...
The difference between one addition operation and two addition operations may not be measurable. But by the 500th or 1000th or more iteration of your loop, the difference between one addition operation and 500 addition operations starts to become noticeable. (And this is minor addition to the time it takes... but when we do find the number, we have to then recalculate it inside your if
branch).
###Memoization
The difference between one addition operation and two addition operations may not be measurable. But by the 500th or 1000th or more iteration of your loop, the difference between one addition operation and 500 addition operations starts to become noticeable. (And this is minor addition to the time it takes... but when we do find the number, we have to then recalculate it inside your if
branch).
There is still a lot to work on for this problem, but I think this answer sets you down a very good path. Think about what this memoization is doing for us, and try to see where we can apply it in other places (especially as you work through Project Euler).