Sieve

in #ita8 days ago

class Sieve {

public static List<Integer> primes(Integer limit) {
    if (limit < 2) return []
    List<Integer>  vet = new ArrayList<Integer>()
    for(int i=2; i<= limit; i++) vet.add(i)
    for(int n=0; n < vet.size(); ++n){
        int num = vet[n]
        vet.removeAll{ it > num && it % num == 0}
    }
     return vet   
    }

}

Sort:  

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.