Description
All Contests ProjectEuler+ Project Euler #1: Multiples of 3 and 5
Project Euler #1: Multiples of 3 and 5
by shashank21j
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
Submissions: 39032
Max Score: 100 Difficulty: Easy
Rate This Challenge:
More
https://www.hackerrank.com/contests/projecteuler/challenges/euler001 1/3 2/24/2017 Project Euler #1: Multiples of 3 and 5 | ProjectEuler+ Question | Contests | HackerRank
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 .
Current Buffer ﴾saved locally, editable﴿ Java 7 ⚙
1▾
2
3
4
5
6
7▾
8
9▾
10
11
12▾
13
14
15
16
17 import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution {
public static void main(String[] args) { Scanner in = new Scanner(System.in);
int t = in.nextInt();
for(int a0 = 0; a0 < t; a0++){
int n = in.nextInt();
}
}
}
Line: 1 Col: 1
https://www.hackerrank.com/contests/projecteuler/challenges/euler001 2/3
Reviews
There are no reviews yet.