tips:
从3设置一个自增量,每次+1,自增后判断是否为3或者5的倍数,是的话累加到sum,最后输出sum.
code:
package main
import "fmt"
func main() {
sum := 0
for i := 3; i < 1000; i++ {
sum += i
}
fmt.Println(sum)
}
2018-12-02 19:12:54
浏览 1033
tips:
从3设置一个自增量,每次+1,自增后判断是否为3或者5的倍数,是的话累加到sum,最后输出sum.
code:
package main
import "fmt"
func main() {
sum := 0
for i := 3; i < 1000; i++ {
sum += i
}
fmt.Println(sum)
}
随时随地看视频慕课网APP