File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
main/java/com/examplehub/projecteuler
test/java/com/examplehub/projecteuler Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .examplehub .projecteuler ;
2+
3+ public class Problem01 {
4+
5+ public static int solution1 (int n ) {
6+ int sum = 0 ;
7+ for (int i = 1 ; i < n ; ++i ) {
8+ if (i % 3 == 0 || i % 5 == 0 ) {
9+ sum += i ;
10+ }
11+ }
12+ return sum ;
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ package com .examplehub .projecteuler ;
2+
3+ import org .junit .jupiter .api .Test ;
4+
5+ import static org .junit .jupiter .api .Assertions .*;
6+
7+ class Problem01Test {
8+
9+ @ Test
10+ void testSolution1 () {
11+
12+ assertEquals (0 , Problem01 .solution1 (-100 ));
13+ assertEquals (0 , Problem01 .solution1 (3 ));
14+ assertEquals (3 , Problem01 .solution1 (4 ));
15+ assertEquals (23 , Problem01 .solution1 (10 ));
16+ assertEquals (233168 , Problem01 .solution1 (1000 ));
17+ }
18+ }
You can’t perform that action at this time.
0 commit comments