47 lines
376 B
Plaintext
Raw Normal View History

2024-08-04 14:17:33 +00:00
import log
import sys
main() {
n := 100
i := 2
loop {
if i > n {
return
}
if isPrime(i) == 1 {
if i != 2 {
sys.write(1, " ", 1)
}
log.number(i)
}
i += 1
}
}
2024-08-05 16:47:24 +00:00
isPrime(x Int) -> Int {
2024-08-04 14:17:33 +00:00
if x == 2 {
return 1
}
if x % 2 == 0 {
return 0
}
i := 3
loop {
if i * i > x {
return 1
}
if x % i == 0 {
return 0
}
i += 2
}
}