有一对刚出生的兔子(一雌一雄)被放生到一个岛上,兔子会不断繁殖,它们在出生后的第一个月不能繁殖,之后每个月结尾时会生出一雌一雄两只兔子。
function getNthFibonacci(count){ count = count * 12; var frist = 1, second = 1, third = 0; if (count > 2) { for(var i = 2; i <= count; i++){ third = frist + second; frist = second; second = third; } return third; } else{ return 1; } }
这道题你会答吗?花几分钟告诉大家答案吧!
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题