Created
August 11, 2014 14:11
-
-
Save jikeytang/b552a7fa0abd973b4ed9 to your computer and use it in GitHub Desktop.
[ Javascript ] - 20140812-题目1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
有一只母乌龟 ,它每年年初生一头小母乌龟 。 | |
每头小母乌龟 从第四个年头开始, | |
每年年初生一头小母乌龟 。 | |
请你计算第n年是共有多少只母乌龟 (第一年是有一头母乌龟) | |
PS: | |
1. 回复时注意加上下面这句话,才会有语法高亮或格式缩进。 | |
```javascript | |
// you code | |
``` | |
2. 粘贴代码时请使用shift+tab,缩进前面的空白。 |
replace5
commented
Aug 12, 2014
function born(num) {
for(var i = 1; i <= num ; i++){
if( i < 4 ){
count ++ ;
}else{
count++;
count + born(i-3);
}
}
return count;
};
console.log(born(12))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment