hic003cih / Golang

0 stars 0 forks source link

for 是 Go 中的 “while” #23

Open hic003cih opened 4 years ago

hic003cih commented 4 years ago

此时你可以去掉分号,因为 C 的 while 在 Go 中叫做 for。

package main

import "fmt"

func main() {
    sum := 1
    for sum < 1000 {
        sum += sum
    }
    fmt.Println(sum)
}