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)
}
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)
}