Sieve

in ita •  6 months ago 

export function primes(num: number): number[] {
const numer: number[] = [];
for(let i=2; i<=num; i++){
if(Isprimes(i)){
numer.push(i);
}
}
return numer;
}

function Isprimes(num: number):boolean {
if(num ==1) return true;
if(num == 2 || num == 3) return true;
if( num % 2== 0 || num % 3 == 0) return false;
let i = 5;
while(num >= i*i){
if( num % i == 0 || num % (i+2) == 0 ) return false;
i +=6;
}
return true;
}

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thank you, friend!
I'm @steem.history, who is steem witness.
Thank you for witnessvoting for me.
image.png
please click it!
image.png
(Go to https://steemit.com/~witnesses and type fbslo at the bottom of the page)

The weight is reduced because of the lack of Voting Power. If you vote for me as a witness, you can get my little vote.