GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — JavaScript/Dynamic-Programming/TribonacciNumber.js at master · TheAlgorithms/JavaScript

Expand file tree

/

TribonacciNumber.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
20 lines (19 loc) · 542 Bytes
/

TribonacciNumber.js

Copy path

File metadata and controls

20 lines (19 loc) · 542 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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.