make/Create a page that displays the first 30 Fibonacci numbers. The output should look something like: First
Fantastic news! We've Found the answer you've been seeking!
Question:
- 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++) {
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date: