Last active
March 27, 2019 14:07
-
-
Save lya79/66d159199166b70d07fd7badec4b5a2c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 prime | |
| import ( | |
| "fmt" | |
| "math" | |
| "testing" | |
| ) | |
| func Test_prime(t *testing.T) { | |
| n := 100 | |
| for i := 2; i <= n; i++ { | |
| prime := true | |
| j := int(math.Sqrt(float64(i))) | |
| for k := 2; k <= j; k++ { | |
| if i%k == 0 { | |
| prime = false | |
| break | |
| } | |
| } | |
| if prime { | |
| fmt.Print(i, ", ") | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment