Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Calculating value of a sequence based on some input using JavaScript
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 −
const num = 13;
const sequenceSum = (num = 1) => {
const res = Math.pow(2, num);
return res;
};
console.log(sequenceSum(num));
Output
8192
Advertisements
