老鼠繁殖问题

开始有两只老鼠,每个月繁殖一对幼鼠,幼鼠三个月长大,即可繁殖,
问二十四个月后共有多少只老鼠(不考虑老鼠死亡、雌雄问题)?
package com.lovo.homework;

public class TestMouse {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

int old = 2,first = 0, second = 0, third = 0;

for(int i = 0; i < 24; i++){
old = old + third;
third = second;
second = first;
first = old;
}

System.out.println(old + first + second + third);
}

}

posted @ 2017-04-29 14:20  风少凌云  阅读(312)  评论(0编辑  收藏  举报