Skip to content

Commit

Permalink
add haha solution
Browse files Browse the repository at this point in the history
  • Loading branch information
haha861924 authored and huibizhang committed Aug 26, 2021
1 parent 76dff58 commit 3c56cb0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions 2021-08/2021-08-26 (day39)/haha/solution.js
Original file line number Diff line number Diff line change
@@ -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)
};

0 comments on commit 3c56cb0

Please sign in to comment.