斐波那契 · 通项公式
跳台阶
http://www.nowcoder.com/questionTerminal/8c82a5b80378478f9484d87d1c5f12a4
通项公式解法:
public class Solution {
public int JumpFloor(int target) {
double k = 1.0/Math.sqrt(5);
double a = (1.0 + Math.sqrt(5))/2.0;
double b = (1.0 - Math.sqrt(5))/2.0;
int n = target + 1;
return (int)(k*(Math.pow(a, n) - Math.pow(b, n)));
}
}

