Skip to content

Instantly share code, notes, and snippets.

@grisza12
Last active March 10, 2016 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grisza12/1624be68a1a4a4b6f979 to your computer and use it in GitHub Desktop.
Save grisza12/1624be68a1a4a4b6f979 to your computer and use it in GitHub Desktop.
oxjVRM
<body>
<input id="wartosc" type="number" />
<button onclick="myFunction()">Fibonnaci</button>
</body>
function myFunction(){
var x = document.getElementById("wartosc").value;
document.write(fib(x));
}
function fib(n) {
var f1 = 1;
var f2 = 1;
var tmp = 0;
document.write();
var start = new Date().getTime();
for (var i = 2; i < n; i++) {
tmp = f1 + f2;
f1 = f2;
f2 = tmp;
}
var stop = new Date().getTime();
var czas = stop - start;
document.write("liczba: "+n+" ciągu fibonnaciego - " +tmp+" Czas wykonania : " + czas + "s ");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment