Skip to content

Commit

Permalink
Attempt p10 in Java
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Sep 16, 2024
1 parent 7c45bcd commit ff82d30
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Olivia's Project Euler Solutions
| | | | |CodeQL| |br| |
| | | | |C#-lint| |
+------------+----------------------------+--------+-------------------+
| Java | Java 8+ in Corretto, |br| | 19 | |Javai| |br| |
| Java | Java 8+ in Corretto, |br| | 20 | |Javai| |br| |
| | Dragonwell, Liberica, |br| | | |Ja-Cov| |br| |
| | Microsoft, Oracle, |br| | | |CodeQL| |br| |
| | Semeru, Temurin, & Zulu | | |Java-lint| |
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Problems Solved
+-----------+-----------+------------+------------+------------+------------+------------+------------+------------+
|:prob:`009`|:c-d:`0009`|:cp-d:`0009`|:cs-d:`0009`|:ja-d:`0009`|:js-d:`0009`|:lu-d:`0009`|:py-d:`0009`|:rs-d:`0009`|
+-----------+-----------+------------+------------+------------+------------+------------+------------+------------+
|:prob:`010`|:c-d:`0010`| |:cs-d:`0010`| |:js-d:`0010`| |:py-d:`0010`|:rs-d:`0010`|
|:prob:`010`|:c-d:`0010`| |:cs-d:`0010`|:ja-d:`0010`|:js-d:`0010`| |:py-d:`0010`|:rs-d:`0010`|
+-----------+-----------+------------+------------+------------+------------+------------+------------+------------+
|:prob:`011`|:c-d:`0011`|:cp-d:`0011`|:cs-d:`0011`|:ja-d:`0011`|:js-d:`0011`|:lu-d:`0011`|:py-d:`0011`|:rs-d:`0011`|
+-----------+-----------+------------+------------+------------+------------+------------+------------+------------+
Expand Down
8 changes: 8 additions & 0 deletions docs/src/java/p0007.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Java Implementation of Problem 7

View source code :source:`java/src/main/java/euler/p0007.java`

Includes
--------

- `Primes.java <./lib/primes.html>`_

Problem Solution
----------------

.. java:type:: public class p0007 implements IEuler
.. java:method:: Object answer()
Expand Down
24 changes: 24 additions & 0 deletions docs/src/java/p0010.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Java Implementation of Problem 10
=================================

View source code :source:`java/src/main/java/euler/p0010.java`

Includes
--------

- `Primes.java <./lib/primes.html>`_

Problem Solution
----------------

.. java:type:: public class p0010 implements IEuler
.. java:method:: Object answer()
:return: The answer to Project Euler problem 10

.. literalinclude:: ../../../java/src/main/java/euler/p0010.java
:language: java
:linenos:

.. tags:: prime-number, java-iterator
1 change: 1 addition & 0 deletions java/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Problems Solved
- ☒ `7 <./src/main/java/p0007.java>`__
- ☒ `8 <./src/main/java/p0008.java>`__
- ☒ `9 <./src/main/java/p0009.java>`__
- ☒ `10 <./src/main/java/p0010.java>`__
- ☒ `11 <./src/main/java/p0011.java>`__
- ☒ `13 <./src/main/java/p0013.java>`__
- ☒ `14 <./src/main/java/p0014.java>`__
Expand Down
19 changes: 19 additions & 0 deletions java/src/main/java/euler/p0010.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Project Euler Problem 10
Problem:
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
*/
package euler;

import euler.lib.Primes;

public class p0010 implements IEuler {
@Override
public Object answer() {
return Primes.primesUntil(2000000L).reduce(0L, Long::sum);
}
}
1 change: 1 addition & 0 deletions java/src/test/java/EulerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static Stream<Object[]> data() throws IOException {
new Object[] { p0007.class, false, Utilities.getAnswer(7) },
new Object[] { p0008.class, false, Utilities.getAnswer(8) },
new Object[] { p0009.class, false, Utilities.getAnswer(9) },
new Object[] { p0010.class, false, Utilities.getAnswer(10) },
new Object[] { p0011.class, false, Utilities.getAnswer(11) },
new Object[] { p0013.class, false, Utilities.getAnswer(13) },
new Object[] { p0014.class, false, Utilities.getAnswer(14) },
Expand Down

0 comments on commit ff82d30

Please sign in to comment.