Created
August 29, 2018 03:26
-
-
Save g14a/a406586115dd8104976564eea8aac6d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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