The Leonardo numbers are a sequence of numbers given by the recurrence: Edsger W. Dijkstra used them as an integral part of his smoothsort algorithm, and also analyzed them in some detail.
function leonardo(n) { var dp = Array(n + 1).fill(0); dp[0] = 1; dp[1] = 1; for(var i = 2; i <= n; i++) { dp[i] = dp[i - 1] + dp[i - 2] + 1; } return dp[n]; }