Skip to content

Instantly share code, notes, and snippets.

@g14a
Created August 29, 2018 03:26
Show Gist options
  • Save g14a/a406586115dd8104976564eea8aac6d3 to your computer and use it in GitHub Desktop.
Save g14a/a406586115dd8104976564eea8aac6d3 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
func main() {
n := 2000
count := 0
for i := 0; ; i++ {
if isPrime(i) {
fmt.Println(i)
count++
}
if count == n {
break
}
}
}
func isPrime(n int) bool {
if n <= 1 {
return false
}
for i := 2; i < n; i++ {
if n%i == 0 {
return false
}
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment