We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #1: Multiples of 3 and 5

Project Euler #1: Multiples of 3 and 5

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 1 from projecteuler.net

If we list all the natural numbers below that are multiples of or , we get and . The sum of these multiples is .

Find the sum of all the multiples of or below .

Input Format

First line contains that denotes the number of test cases. This is followed by lines, each containing an integer, .

Constraints

Output Format

For each test case, print an integer that denotes the sum of all the multiples of or below .

Sample Input 0

2
10
100

Sample Output 0

23
2318

Explanation 0

For , if we list all the natural numbers below that are multiples of or , we get and . The sum of these multiples is .

Similarly for , we get .

Author

shashank21j

Difficulty

Easy

Max Score

100

Submitted By

112726

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy