diff --git a/2021-08/2021-08-26 (day39)/haha/solution.js b/2021-08/2021-08-26 (day39)/haha/solution.js new file mode 100644 index 00000000..cb28d480 --- /dev/null +++ b/2021-08/2021-08-26 (day39)/haha/solution.js @@ -0,0 +1,10 @@ +/** + * @param {number} n + * @return {number} + */ +var climbStairs = function (n) { + if (n < 2) return n + let ratio = (1 + Math.sqrt(5)) / 2 + let ratioAlt = (1 - Math.sqrt(5)) / 2 + return (Math.pow(ratio, n + 1) - Math.pow(ratioAlt, n + 1)) / Math.sqrt(5) +}; \ No newline at end of file