[Project Euler in Groovy] - P1


/ Published in: Groovy
Save to your folder(s)

Project Euler in Groovy, Problem 1


Copy this code and paste it in your HTML
  1. final def MAX = 1000
  2. def sum = 0
  3. (3..MAX-1).each {
  4. if (it % 3 == 0 || it % 5 == 0) {
  5. sum += it
  6. }
  7. }
  8. println "sum => $sum"

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.