Climbing Stairs

You are climbing a stair case. It takes n steps to reach to the top.

Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

/**
 * @param {number} n
 * @return {number}
 */

var climbStairs=function(n){
	if(n<4) return n;
	var a=2,b=3,c=5;
	for(var i=5;i<=n;i++){
		a=c;
		c=b+c;
		b=a;
	}
	return c;
};

原文地址:https://www.cnblogs.com/code-charmer/p/4852494.html