Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 00ad54e5e8
Fetching contributors…

Cannot retrieve contributors at this time

file 40 lines (34 sloc) 0.606 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
println "This program lists all the primes numbers from 1 to 1000: "
println "1"
println "2"
int test = 3
int divisor = 2
boolean isPrime = true
while (test < 1000) {
if (divisor == (test - 1)) {
if (test % divisor == 0) {
isPrime = false
test = test + 2
divisor = 2
}
else if (test % divisor != 0) {
isPrime = true
}
if (isPrime) {
println test
test = test + 2
divisor = 2
}
}
else if (divisor < test) {
if (test % divisor == 0) {
isPrime = false
test = test + 2
divisor = 2
}
else if (test % divisor != 0) {
divisor++
isPrime = false
}
}





}

Something went wrong with that request. Please try again.