VB icon

Fibonacci Number Sequence in JavaScript

Email
Submitted on: 5/14/2016 1:46:30 AM
By: Jake R. Pomperada  
Level: Beginner
User Rating: Unrated
Compatibility: JavaScript
Views: 2734
author picture
 
     A simple program that I wrote in JavaScript to accept a number from the user and then our program will generate the corresponding Fibonacci Number Sequence. Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com My mobile number here in the Philippines is 09173084360.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Fibonacci Number Sequence in JavaScript
' Description:A simple program that I wrote in JavaScript to accept a number from the user and then our program will generate the corresponding Fibonacci Number Sequence.
Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com
My mobile number here in the Philippines is 09173084360.
' By: Jake R. Pomperada
'**************************************

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title> Fibonacci Sequence in JavaScript</title>
<style>
body {
 font-family:arial;
 color:blue;
 font-size:18px;
 }
 
 input[type="text"] {
 display: block;
 margin: 0;
 width: 15%;
 font-family: arial;
 font-size: 18px;
 appearance: none;
 border-radius: 2px;
 box-shadow: 10px 10px 7px #888888;
}
input[type="text"]:focus {
 outline: none;
}
input[type=button] {
padding:12px 31px; 
background:yellow; border:10px;
cursor:pointer;
-webkit-border-radius: 12px;
box-shadow: 10px 10px 7px #888888;
border-radius: 5px; 
font-family: arial;
font-size: 18px;
}
</style>
</head>
<body bgcolor="lightgreen">
<script>
	
function start_fibonacci() {
var num, first = 0, second = 1, next, c;
var value_number = document.getElementById("UserInput").value
var num = Number(value_number);
 for ( c = 0 ; c < num ; c++ )
{
 if ( c <= 1 )
 next = c;
 else
 {
 next = first + second;
 first = second;
 second = next;
 }
 	
	document.getElementById('result').innerHTML += + next + "<br>";
	 
}
}
		function clear_now()
		{
		 document.getElementById('result').innerHTML="";
		 document.getElementById('userInput').value="";
		 document.getElementById('userInput').focus();
		} 		
	</script>
<b> Fibonacci Sequence in JavaScript </b> <br><br>
<form name="myform" action="">
<b>Give a Number </b><br><br>
<input type='text' id='UserInput' placeholder="enter number here" value='' size="5" required autofocus/>
<br><br>
<input type='button' onclick='start_fibonacci()' 
title="Click here to generated fibonacci sequence number." value='OK'/>
      
<input type='button' onclick='clear_now()' title="Click here to clear the textbox." value='CLEAR'/>
</form>
<br><br>
</body>
Fibonacci Sequence Result 
<br><br>
<div id = "result"></div> 
</html>


Other 108 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.