Skip to content

Instantly share code, notes, and snippets.

@lya79
Last active March 27, 2019 14:07
Show Gist options
  • Select an option

  • Save lya79/66d159199166b70d07fd7badec4b5a2c to your computer and use it in GitHub Desktop.

Select an option

Save lya79/66d159199166b70d07fd7badec4b5a2c to your computer and use it in GitHub Desktop.
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