Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- fn main() {
- max_n := arguments()[1] or { '100_000' }.int()
- t := time.now()
- mut primes := []int{cap: max_n}
- primes << 2
- mut check := 3
- mut index := 1
- for index < max_n {
- mut is_prime := true
- for prime in primes {
- if (check % prime) == 0 {
- is_prime = false
- break
- }
- }
- if is_prime {
- primes << check
- index += 1
- }
- check += 2
- }
- println(primes.len)
- println(time.since(t))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement