mirror of
https://github.com/vlang/v.git
synced 2025-08-04 02:07:28 -04:00
25 lines
322 B
V
25 lines
322 B
V
fn is_prime(n int) bool {
|
|
if n <= 1 {
|
|
return false
|
|
}
|
|
for i := 2; i * i <= n; i++ {
|
|
if n % i == 0 {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
fn main() {
|
|
how_many := arguments()[1] or { '10' }.int()
|
|
mut count := 0
|
|
mut num := 2
|
|
for count < how_many {
|
|
if is_prime(num) {
|
|
println(num)
|
|
count++
|
|
}
|
|
num++
|
|
}
|
|
}
|