JavaScript - Build with Node.js Follow the instructions bellow for a good rate C
ID: 3749612 • Letter: J
Question
JavaScript - Build with Node.js
Follow the instructions bellow for a good rate
Create a program that will display the result of three functions:
a) sum every second element from the Fibonacci sequence (starting with id 0, maximum of 20 numbers in the sequence)
b) the sum should be divided by randomly generated number (in a range from 50 to 100)
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.
Explanation / Answer
<!DOCTYPE html>
<html>
<title>Web Page Design</title>
<head>
<script>
var i,sum=0;
var fib = []; // Initialize array!
fib[0] = 0;
fib[1] = 1;
for(i=2; i<=20; i++)
{
fib[i] = fib[i-2] + fib[i-1];
console.log(fib[i]);
}
for(i=0;i<=10;i++){
if(i%2!=0)
sum=sum+fib[i];
}
console.log(sum/Math.random()*100);
</script>
</head>
<body>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.