Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
Enter number: <input id="input" type="text">
<input onclick="printFib(document.getElementById('input').value)" type="button" name="submit" value="Submit">
<p id="output"></p>
var output = document.getElementById("output");
function printFib(num) {
output.innerHTML = "";
var a = 0, b = 1;
output.innerHTML = a;
while(b <= num) {
output.innerHTML = output.innerHTML + "," + b;
b = a + b;
a = b - a;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.