Groovy web console

subscribe to the feed Subscribe
to this
site

Divisible by 3

Published 1 month ago by Anonymous
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
def x = [1,3,5,5,]
// Sort to do
println x.sum()
def s = x.sum()
def r = s % 3
def d = []
if (s == 0) {
  println x
} else {
  for (def i = 0; i < x.size(); i++) {
    println x[i]%3
    if (x[i] % 3 == r) {
      x.remove(i)
      println x
    }
  }
}