一只青蛙一次能够跳上1级台阶,也能够跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法

//思考当n>2 要跳n阶和n-1,n-2有关code

public class Solution {get

public int JumpFloor(int target) {

    if(target==1 ||target==2)
	
        return target;
		
    int f1=1,f2=2,fn=0,i=3;
	
    while(i<=target){
	
        fn=f1+f2;
		
        f1=f2;
		
        f2=fn;
		
        i++;
		
    }
	
    return fn;
	
}

}io