GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — JavaScript/Dynamic-Programming/TribonacciNumber.js at master · TheAlgorithms/JavaScript Expand file tree/ Copy pathTribonacciNumber.jsMore file actions 20 lines (19 loc) · 542 Bytes / Copy pathTribonacciNumber.jsFile metadata and controls20 lines (19 loc) · 542 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 /** * @function Tribonacci * @description Tribonacci is the sum of previous three tribonacci numbers. * @param {Integer} n - The input integer * @return {Integer} tribonacci of n. * @see [Tribonacci_Numbers](https://www.geeksforgeeks.org/tribonacci-numbers/) */ const tribonacci = (n) => { // creating array to store previous tribonacci numbers const dp = new Array(n + 1) dp[0] = 0 dp[1] = 1 dp[2] = 1 for (let i = 3; i <= n; i++) { dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3] } return dp[n] } export { tribonacci } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |