GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — JavaScript/Project-Euler/Problem010.js at master · TheAlgorithms/JavaScript

Expand file tree

/

Problem010.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
24 lines (21 loc) · 489 Bytes
/

Problem010.js

Copy path

File metadata and controls

24 lines (21 loc) · 489 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// https://projecteuler.net/problem=10
const isPrime = (number) => {
if (number === 2) return true
if (number % 2 === 0) return false
for (let j = 3; j * j <= number; j += 2) {
if (number % j === 0) {
return false
}
}
return true
}
const calculateSumOfPrimeNumbers = (maxNumber) => {
let sum = 0
for (let i = maxNumber - 1; i >= 2; i--) {
if (isPrime(parseInt(i)) === true) {
sum += i
}
}
return sum
}
export { calculateSumOfPrimeNumbers }
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.