Question: JavaScript Follow the instructions bellow for a good rate Create a program that will display the result of three functions: a) sum the elements from

JavaScript

Follow the instructions bellow for a good rate

Create a program that will display the result of three functions: a) sum the elements from the Fibonacci sequence b) divide them by randomly generated number c) calculate factorial from the rounded result of previous operation

Functions should be stored in one, separate file. The main program should run from the app.js. Finally, a user should provide input for two variables - the number of Fibonacci items and the number responsible for the range of the randomly generated number from point b)

-----------------------------------------------------------------

Code for app.js is showen bellow:

app.js:

function calculateFibonacci(num) { var a = 1, b = 0, temp;

while (num >= 0) { temp = a; a = a + b; b = temp; num--; }

return b; }

function displayFibonacci(s) { var result = ""; for (i = s; i > 0; i--) { result += calculateFibonacci(i) + ", "; } return result.substring(0, result.length - 2); }

console.log(displayFibonacci(21));

--------------------------------------------------------------------

Output in Console:

17711, 10946, 6765, 4181, 2584, 1597, 987, 610, 377, 233, 144, 89, 55, 34, 21, 13, 8, 5, 3, 2, 1 [Finished in 0.9s]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!