fork download
  1. def len = 10
  2. boolean [] arr = new boolean[len]
  3. arr[0] = false;//Fill 1, arr[1] =3
  4.  
  5. def times = Math.sqrt(len) + 2
  6. for(def i = 1; i < times; i++){
  7. def j = i;
  8. def dist = i+i+1;
  9. j += dist;
  10. for(; j < len; j=dist+j){
  11. arr[ j ] = false;
  12. }
  13. arr.eachWithIndex{v,i ->println v; println i*2+1 }
  14. }
  15. arr.eachWithIndex{v,i ->println v; println i*2+1 }
Runtime error #stdin #stdout 0.94s 219072KB
stdin
Standard input is empty
stdout
Standard output is empty