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.  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  
  2. 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

1 Expert Approved Answer
Step: 1 Unlock

To create a page that displays the first 30 Fibonacci numbers you can use Java... View full answer

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 Programming Questions!