Skip to content

Instantly share code, notes, and snippets.

@jikeytang
Created August 11, 2014 14:11
Show Gist options
  • Save jikeytang/b552a7fa0abd973b4ed9 to your computer and use it in GitHub Desktop.
Save jikeytang/b552a7fa0abd973b4ed9 to your computer and use it in GitHub Desktop.
[ Javascript ] - 20140812-题目1
有一只母乌龟 ,它每年年初生一头小母乌龟 。
每头小母乌龟 从第四个年头开始,
每年年初生一头小母乌龟 。
请你计算第n年是共有多少只母乌龟 (第一年是有一头母乌龟)
PS:
1. 回复时注意加上下面这句话,才会有语法高亮或格式缩进。
```javascript
// you code
```
2. 粘贴代码时请使用shift+tab,缩进前面的空白。
@replace5
Copy link

function tortoise_count(y) {
    return Math.pow(Math.floor(y/4));
}

@wsgouwan
Copy link

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