package main import ( "fmt" "math" ) func main() { i := 2 num := 1 for num <= 10001 { if Prime(i) { num++ } i++ } fmt.Println(i - 1) } func Prime(num int) bool { if num == 2 || num == 3 { return true } if num%6 != 1 && num%6 != 5 { return false } tmp := int(math.Sqrt(float64(num))) for i := 5; i <= tmp; i += 6 { if num%i == 0 || num%(i+2) == 0 { return false } } return true }
结果:104743
原文地址:https://www.cnblogs.com/miria-486/p/10093002.html
时间: 2024-10-10 23:57:16