Skip to content

Instantly share code, notes, and snippets.

@aeg
Created August 13, 2012 03:15
Show Gist options
  • Save aeg/3336645 to your computer and use it in GitHub Desktop.
Save aeg/3336645 to your computer and use it in GitHub Desktop.
素数のときに":counted!"と表示する
def MaxNumber = 100
def NotPrime = []
(1..MaxNumber).each {
print it
if ((it >1) && (NotPrime[it] != 1 )) {
for (def num = it * 2; num <= MaxNumber; num+= it) {
NotPrime[num] = 1
}
println ":counted!"
} else {
println ""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment