github.com/traefik/yaegi@v0.15.1/_test/primes.go (about) 1 package main 2 3 func Primes(n int) int { 4 var xs []int 5 for i := 2; len(xs) < n; i++ { 6 ok := true 7 for _, x := range xs { 8 if i%x == 0 { 9 ok = false 10 break 11 } 12 } 13 if !ok { 14 continue 15 } 16 xs = append(xs, i) 17 } 18 return xs[n-1] 19 } 20 21 func main() { 22 println(Primes(3)) 23 } 24 25 // Output: 26 // 5