老耗子生小耗子问题

package com.lovo.test; public class homeWork_3 { public static void main(Str
package com.lovo.test;


public class homeWork_3 {


public static void main(String[] args) {
// 4.一队老耗子,每个月都生一对小耗子,小耗子长3个月,第四个月开始变成老耗子开始生,
// 假设所有耗子都不死,请问20个月之后共有多少只耗子?//
int old = 2, first = 0,second = 0,third = 0,sum = 0;
        for(int i =0 ;i < 20 ; i++){
        old = old + third;
        third = second;
        second = first;
        first = old;
        System.out.println(old +" "+ third+" " + second+" "+ first);
        }
        System.out.println(old + third + second+ first); 
}
}