Question

JavaScript for a HTML webpage code a Fibonacci Sequence, have the user defining the number of...

JavaScript

for a HTML webpage code a Fibonacci Sequence, have the user defining the number of runs. (use a function and either While or For statement)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

<html lang="en">

<head>

<body>
<script type="text/javascript">
var f1 = 0,
f2 = 1,
f3;
var i;
var n = prompt("Enter number");
document.write("First ");
document.write(n);
document.write(" fibonacci numbers are " + "<br/>");
if (n >= 1)
document.write(0 + "<br/>");
if (n >= 2)
document.write(1 + "<br/>");
if (n > 2) {
for (i = 2; i < n; i++) {
f3 = f1 + f2;
f1 = f2;
f2 = f3;
document.write(f3 + "<br/>");
}
}
</script>
<style>
</style>

</head>
</body>

\color{red}\underline{Output:}

new 4html C file:///E/new%204.html First 30 fibonacci numbers are 13 21 89 144 233 377 610 987 1597 2584 4181 6765 10946 2865

Add a comment
Know the answer?
Add Answer to:
JavaScript for a HTML webpage code a Fibonacci Sequence, have the user defining the number of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JavaScript Just use javascript, dont include HTML Follow the instructions bellow for a good rate Create...

    JavaScript Just use javascript, dont include HTML 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 that is provided bellow, the other file should be called module.js that includes...

  • Create a webpage (the last picture has three potential offers not just 2). Use html, JavaScript...

    Create a webpage (the last picture has three potential offers not just 2). Use html, JavaScript and CSS where needed. All information needed is supplied by the picture. Summary Create a dynamic web page that allows users to compare different financing offers for an automobile loan. Purchasers are often presented with different financing offers, and determining the best offer can be difficult. In particular, dealers often have promotions that offer either a lower interest rate or a cash incentive (sometimes...

  • Create a webpage in which the user is allowed to select the page's background and color...

    Create a webpage in which the user is allowed to select the page's background and color whether the page uses serif or sans serif fonts. The change the body element's style attribute accordingly. If the user onclicks any of the options, the webpage will turn into that format. For example, if the user clicks "Gray background", the background color of the webpage will be Gray. If the user clicks Serif-text, the text in the web page will be in Serif...

  • c++ code that outputs the 25th number in the fibonacci sequence

    c++ code that outputs the 25th number in the fibonacci sequence

  • IT MUST USE PHP AND HTML IT CANT BE JAVASCRIPT IT HAS TO BE PHP AND...

    IT MUST USE PHP AND HTML IT CANT BE JAVASCRIPT IT HAS TO BE PHP AND HTML Using PHP and HTML 5, create a webpage that calculates the monthly payment for a car loan. The user enters the price of the car (P), down payment (D), Annual Percentage Rate (R), and the number of years (N). Compute the monthly payment (M) using the following formula and display it: Let i = R / 1200 and n = N * 12;...

  • i need help with this homework webpage and code too: The webpage must include: Global Structure...

    i need help with this homework webpage and code too: The webpage must include: Global Structure Tags Text Tags Images   Your first page must be named index.html Include a table within your site, challenge yourself to add a header in the table, and choose interesting border and/or cell formatting. Include a hyperlink within your site. Include an image in your site. Include a form in your site to demonstrate understanding of a variety of form components (the form does not...

  • Write a html javascript program to do the following: the user inputs a number, for example,...

    Write a html javascript program to do the following: the user inputs a number, for example, 50 user presses a button, labeled START the program creates 50 random buttons around the browser window each button should be placed at a random location each button should be labeled with a random number between 1 and 50 add the following features every 2 seconds, move each button around by increment or decrementing its location if the user clicks on a button, change...

  • NEED HELP with HTML with Javascript embedding for form validation project below. I have my code...

    NEED HELP with HTML with Javascript embedding for form validation project below. I have my code below but I'm stuck with validation. If anyone can fix it, I'd really appreciate. ****************************************************************************** CODE: <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title>Nice</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> var textFromTextArea; function getWords(){ var text =...

  • 4. One interesting property of a Fibonacci sequence is that the ratio of the values of...

    4. One interesting property of a Fibonacci sequence is that the ratio of the values of adjacent members of the sequence approaches a number called "the golden ratio". Create a program that accepts the first two numbers of a Fibonacci sequence as user input and then calculates additional values in the sequence until the ratio of adjacent values converges to within 0.001 You can do this in a while loop by comparing the ratio of element k to element k...

  • This is my code so far: <!DOCTYPE html> <html> <head> <title>JavaScript is fun</title> <meta charset="utf-8" />...

    This is my code so far: <!DOCTYPE html> <html> <head> <title>JavaScript is fun</title> <meta charset="utf-8" /> </head> <body> <script type ="text/javascript"> //declare a variable and store text in it var x = "JavaScript is fun"; //write the variable 5 times document.write(x + x + x + x + x); //store 5 as string in variable x x = "5"; //store 3 as string in variable y var y = "3"; //write the value x + y to the document document.write("<br>");...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT