斐波那契数列迭代算法

链接: https://www.nowcoder.com/questionTerminal/72a5a919508a4251859fb2cfb987a0e6
来源:牛客网

  public int RectCover( int target) {
         int tempNum = 1 ;
         int result = 2 ;
         
         if (target == 0 ) {
             return 1 ;
         }
         
         if (target == 1 || target == 2 ) {
             return target;
         }
         
         int count = 2 ;
         while (count < target) {
             result += tempNum;
             tempNum = result - tempNum;
             count ++;
         }
         return result;
     }

你可能感兴趣的:(斐波那契数列迭代算法)