Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Java algorithm - Sum of all multiples of 3 or 5 that are below a number n

Sometimes, use of simple algebra improves performance like anything. Let's explore below problem and its probable solution and observer how performance is increased multiple times by just using the simple algebra. ProblemIf we list all the Natural Numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. If we list all the natural numbers below 20



This post first appeared on Instant Kick, please read the originial post: here

Share the post

Java algorithm - Sum of all multiples of 3 or 5 that are below a number n

×

Subscribe to Instant Kick

Get updates delivered right to your inbox!

Thank you for your subscription

×