Calculating value of a sequence based on some input using JavaScript

JavascriptWeb DevelopmentFront End Technology

Problem

We are required to write a JavaScript function that takes in a number n as the only input. Suppose a sequence u for which,

u1 = 0 and u1 = 2

Our function should find the of un for which,

6unun+1- 5unun+2+un+1un+2 = 0

Example

Following is the code −

 Live Demo

const num = 13;
const sequenceSum = (num = 1) => {
   const res = Math.pow(2, num);
   return res;
};
console.log(sequenceSum(num));

Output

8192
raja
Published on 20-Apr-2021 09:13:00
Advertisements