Skip to content

Commit

Permalink
solve p10 in javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Aug 9, 2024
1 parent 93ceb27 commit c7c3c22
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Olivia's Project Euler Solutions
| | | | |CodeQL| |br| |
| | | | |C#-lint| |
+------------+--------------------------+--------+-------------------+
| JavaScript | Node 12+ |br| | 18 | |JavaScript| |br| |
| JavaScript | Node 12+ |br| | 19 | |JavaScript| |br| |
| | Bun 1.0+ |br| | | |Js-Cov| |br| |
| | Firefox [2]_ |br| | | |CodeQL| |br| |
| | Chrome [2]_ | | |ESLint| |
Expand Down
18 changes: 18 additions & 0 deletions docs/javascript/p0010.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
JavaScript Implementation of Problem 10
=======================================

View source code :source:`javascript/src/p0010.js`

Includes
--------

- `primes <./primes.html>`_

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

.. js:autofunction:: p0010

.. literalinclude:: ../../javascript/src/p0010.js
:language: javascript
:linenos:
1 change: 1 addition & 0 deletions javascript/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Problems Solved
- ☒ `7 <./src/p0007.js>`__
- ☒ `8 <./src/p0008.js>`__
- ☒ `9 <./src/p0009.js>`__
- ☒ `10 <./src/p0010.js>`__
- ☒ `11 <./src/p0011.js>`__
- ☒ `13 <./src/p0013.js>`__
- ☒ `17 <./src/p0017.js>`__
Expand Down
1 change: 1 addition & 0 deletions javascript/euler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const answers = {
7: [require('./src/p0007.js'), false],
8: [require('./src/p0008.js'), false],
9: [require('./src/p0009.js'), false],
10: [require('./src/p0010.js'), false],
11: [require('./src/p0011.js'), false],
13: [require('./src/p0013.js'), false],
14: [require('./src/p0014.js'), false],
Expand Down
22 changes: 22 additions & 0 deletions javascript/src/p0010.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Project Euler Problem 10
*
* Yet again, having a good prime number infrastructure comes in handy
*
* Problem:
*
* The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
*
* Find the sum of all the primes below two million.
*
* @return {number}
*/
exports.p0010 = function() {
let answer = 0;
for (p of primes.primes(2000000)) {
answer += p;
}
return answer;
};

const primes = require('./lib/primes.js');

0 comments on commit c7c3c22

Please sign in to comment.