Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Your isPrime function fails for 3 (sqrt(3) < 2, creating an invalid range).
Also, your solution has a worst-case complexity of O(n²); there's a more clever way to do what you're doing without checking all previous primes each time.
In keeping with the functional programming paradigm it is best not to change the value of the arguments.
This is why I voted this solution as best practice. Instead of sum I would probably use present_value this is because I worked for a Bank and when we modelled securities this is the term we would use. This solution is also easy to follow, has great comments and demonstrates a good understanding of
ruby by the way you have initialized the values and returned the result.