diff --git a/README.rst b/README.rst index 9b712721..6cdaea9c 100644 --- a/README.rst +++ b/README.rst @@ -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| | diff --git a/docs/index.rst b/docs/index.rst index a0b0275a..45d8226a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -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`| +-----------+-----------+------------+------------+------------+------------+------------+------------+------------+ diff --git a/docs/src/java/p0007.rst b/docs/src/java/p0007.rst index f766a43d..ea84e911 100644 --- a/docs/src/java/p0007.rst +++ b/docs/src/java/p0007.rst @@ -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() diff --git a/docs/src/java/p0010.rst b/docs/src/java/p0010.rst new file mode 100644 index 00000000..8f55fd4d --- /dev/null +++ b/docs/src/java/p0010.rst @@ -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 diff --git a/java/README.rst b/java/README.rst index d44fe695..3f201d08 100644 --- a/java/README.rst +++ b/java/README.rst @@ -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>`__ diff --git a/java/src/main/java/euler/p0010.java b/java/src/main/java/euler/p0010.java new file mode 100644 index 00000000..59cd8e80 --- /dev/null +++ b/java/src/main/java/euler/p0010.java @@ -0,0 +1,21 @@ +/* +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) + .filter(i -> i != null) + .reduce(0L, Long::sum); + } +} \ No newline at end of file diff --git a/java/src/test/java/EulerTest.java b/java/src/test/java/EulerTest.java index 5c0246a3..0431b5fc 100644 --- a/java/src/test/java/EulerTest.java +++ b/java/src/test/java/EulerTest.java @@ -22,6 +22,7 @@ static Stream 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) },