Skip to content

Instantly share code, notes, and snippets.

@jthomas jthomas/primes.js
Created May 10, 2019

Embed
What would you like to do?
'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
You can’t perform that action at this time.