Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

1. Describe the types of power that effective leaders employ

Answered: 1 week ago