老鼠繁殖問題

開始有兩隻老鼠,每月繁殖一對幼鼠,幼鼠三個月長大,便可繁殖,
問二十四個月後共有多少隻老鼠(不考慮老鼠死亡、雌雄問題)?
package com.lovo.homework;class

public class TestMouse {static

/**
* @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);
}co

}void

相關文章
相關標籤/搜索