1 Star 0 Fork 52

shiyifeng/c2go

forked from Apocalypse/c2go 
Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
2.go 386 Bytes
Copy Edit Raw Blame History
ZenQy authored 2015-03-29 18:12 . last push
// 判断 101-200 之间有多少个素数,并输出所有素数。
package main
import (
"fmt"
"math"
)
func main() {
count := 0 //合数个数
for i := 101; i <= 200; i++ {
mid := int(math.Sqrt(float64(i)))
for j := 2; j <= mid; j++ {
if i%j == 0 {
//fmt.Println(i)//符合条件的即为合数
count = count + 1
break
}
}
}
fmt.Println(100 - count)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/shiyifeng/c2go.git
git@gitee.com:shiyifeng/c2go.git
shiyifeng
c2go
c2go
master

Search

0d507c66 1850385 C8b1a773 1850385