题解 | #统计每个月兔子的总数#

统计每个月兔子的总数

https://www.nowcoder.com/practice/1221ec77125d4370833fd3ad5ba72395

package main

import (
	"fmt"
)

func main() {
	month := 0
	fmt.Scan(&month)

	father, child := 1, 0
	for ; month > 1; month-- {
		father, child = father+child, father
	}
    fmt.Println(father)
}

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务