Daily Java “Day 29” Codewars (6 Kyu) Multiples Of 3 And 5

Skip to content

This problem is taken from Codewars.com ( the level of this problem is 6 Kyu ) here.

Problem: If 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.

Finish the solution so that it returns the sum of all the multiples of 3 or 5 below the number passed in.

Note: If the number is a multiple of both 3 and 5, only count it once.

Courtesy of ProjectEuler.net

Solution: A number is a multiple of 3 or 5 if the number yields no remainder after divided by 3 or 5. We can use for-loop and if method to solve this problem.

Source Code: multiplesof3and5

Output: multiplesof3and5a.jpg

Share this:

  • X
  • Facebook
Like Loading...

Leave a comment Cancel reply

Δ

Post navigation Daily Java “Day 28” codewars (6 kyu) Backwards Read PrimesDaily Java “Day 30” Codewars (6 kyu) Single Word Pig Latin Menu
  • Comment
  • Reblog
  • Subscribe Subscribed
    • Daily Programming
    • Sign me up
    • Already have a WordPress.com account? Log in now.
    • Daily Programming
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Copy shortlink
    • Report this content
    • View post in Reader
    • Manage subscriptions
    • Collapse this bar
Loading Comments... Write a Comment... Email (Required) Name (Required) Website %d Design a site like this with WordPress.comGet started

Tag » Codewars 6 Kyu Solutions Java