fun main(args : Array<String>) {
var initial = 1
val final = 100
while (initial < final) {
if (printPrimeNumber(initial))
print(initial.toString() + " ")
++initial
}
}
fun printPrimeNumber(num: Int): Boolean {
var flag = true
for (i in 2..num / 2) {
if (num % i == 0) {
flag = false
break
}
}
return flag
}
Solution:
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer