Script Categories













Calculators >>> Fibonacci.

Displays the Fibonacci Sequence of Numbers as entered by the user. Warning: This is very processor intensive, do not enter a large number.

Computations:
Sequence:

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function f(n) {
var s = 0;
if(n == 0) return(s);
if(n == 1) {
s += 1;
return(s);
}
else {
return(f(n - 1) + f(n - 2));
   }
}
function show(n) {
var i;
for(i = 0; i <= n; i++) {
document.f1.s.value += "  " + f(i);
   }
}
//  End -->
</script>
<form name=f1>
Computations: <input type=text size=4 name="n">
<input type=button value="Compute" onClick="show(f1.n.value);">
<input type=reset value="Reset"><br>
Sequence: <input type=text size="100" name="s">
</form>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).

R7


©