Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jun 29, 2025. It is now read-only.

Commit c35550f

Browse files
committed
Started working Project Euler problems
1 parent a81786b commit c35550f

File tree

2 files changed

+47
-19
lines changed

2 files changed

+47
-19
lines changed

‎Java/.idea/workspace.xml‎

Lines changed: 20 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package problems.project_euler;
2+
3+
import java.util.ArrayList;
4+
5+
/**
6+
* If we list all the natural numbers below 10 that are multiples of 3 or 5, we get
7+
* 3, 5, 6 and 9.
8+
* The sum of these multiples is 23.
9+
*
10+
* Find the sum of all the multiples of 3 or 5 below 1000.
11+
*/
12+
13+
public class MultiplesOf3And5 {
14+
15+
public static void main(String[] args) {
16+
System.out.println(multiplesBelowN(1000));
17+
}
18+
19+
private static int multiplesBelowN(int n){
20+
int sum = 0;
21+
for (int i = 0; i < 1000; i++) {
22+
if (i % 3 == 0 || i % 5 == 0)
23+
sum += i;
24+
}
25+
return sum;
26+
}
27+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /