Skip to content

Commit a12a3ed

Browse files
author
Gonzalo Diaz
committed
[Hacker Rank]: Project Euler #1: Multiples of 3 and 5. Documentation added.
1 parent f99f948 commit a12a3ed

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

algorithm-exercises-csharp/src/hackerrank/projecteuler/Euler001.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @link Problem definition [[docs/hackerrank/projecteuler/euler001.md]]
2+
13
namespace algorithm_exercises_csharp.hackerrank.prohecteuler;
24

35
using System.Diagnostics.CodeAnalysis;

docs/.gitkeep

Whitespace-only changes.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# [Multiples of 3 and 5](https://www.hackerrank.com/contests/projecteuler/challenges/euler001)
2+
3+
- Difficulty: #easy
4+
- Category: #ProjectEuler+
5+
6+
If we list all the natural numbers below $ 10 $ that are multiples of
7+
$ 3 $ or $ 5 $, we get $ 3, 5, 6 $ and $ 9 $.
8+
The sum of these multiples
9+
is $ 23 $.
10+
11+
Find the sum of all the multiples of $ 3 $ or $ 5 $ below $ N $.
12+
13+
## Input Format
14+
15+
First line contains $ T $ that denotes the number of test cases.
16+
This is followed by $ T $ lines, each containing an integer, $ N $.
17+
18+
## Constraints
19+
20+
- 1 $ \leq T \leq 10^5 $
21+
- 1 $ \leq N \leq 10^9 $
22+
23+
## Output Format
24+
25+
For each test case, print an integer that denotes the sum of all the multiples
26+
of $ 3 $ or $ 5 $ below $ N $.
27+
28+
## Sample Input 0
29+
30+
```text
31+
2
32+
10
33+
100
34+
```
35+
36+
## Sample Output 0
37+
38+
```text
39+
23
40+
2318
41+
```
42+
43+
## Explanation 0
44+
45+
For $ N = 10 $, if we list all the natural numbers below $ 10 $ that are
46+
multiples of $ 3 $ or $ 5 $, we get $ 3, 5, 6 $ and $ 9 $.
47+
The sum of these multiples is $ 23 $.
48+
49+
Similarly for $ N = 100 $, we get $ 2318 $.

0 commit comments

Comments
 (0)