Skip to content

Instantly share code, notes, and snippets.

@jthomas
Created May 10, 2019 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jthomas/71c76d62ddfd146c4bf763f5b2f0eec1 to your computer and use it in GitHub Desktop.
Save jthomas/71c76d62ddfd146c4bf763f5b2f0eec1 to your computer and use it in GitHub Desktop.
'use strict';
const min = 2
function main(params) {
const { start, end } = params
console.log(params)
const primes = []
let isPrime = true;
for (let i = start; i < end; i++) {
for (let j = min; j < Math.sqrt(end); j++) {
if (i !== j && i%j === 0) {
isPrime = false;
break;
}
}
if (isPrime) {
primes.push(i);
}
isPrime = true;
}
return { primes }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment