Answered step by step
Verified Expert Solution
Question
1 Approved Answer
make/Create a page that displays the first 30 Fibonacci numbers. The output should look something like: First 30 Fibonacci Numbers 1 - 1 2 -
- make/Create a page that displays the first 30 Fibonacci numbers. The output should look something like:
- First 30 Fibonacci Numbers
- 1 - 1 2 - 1 3 - 2 4 - 3 5 - 5 6 - 8 7 - 13 8 - 21 ... 27 - 196418 28 - 317811 29 - 514229 30 - 832040
- First 30 Fibonacci Numbers
- The output numbers in this sequence are the first two and then after the second number the sum of the previous numbers. To correctly output the numbers, use logic similar to the following:
- Declare all variables needed.
- Display your page title.
- Display the first variable with a value of 1, example: "1 - 1"
- Display the second variable with a value of 1, Example: "2 - 1"
- Start a for loop giving the counter a value of 3.
- Test the counter to ensure a value less than or equal to 30.
- Assign a totalizer variable with the added values of the first and second variables.
- Output the values of counter and totalizer each iteration.
- Assign the first variable the value of the second.
- Assign the second variable the value of the totalizer.
- Increment the counter.
- Test the loop again.
- Use document.write to display the output.
- Syntax help:
- for (counter = 3; counter <= 30; counter++) {
Step by Step Solution
There are 3 Steps involved in it
Step: 1
To create a page that displays the first 30 Fibonacci numbers you can use Java...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started