Skip to content

Instantly share code, notes, and snippets.

@sauravtom
Created February 13, 2013 04:04
Show Gist options
  • Select an option

  • Save sauravtom/4942175 to your computer and use it in GitHub Desktop.

Select an option

Save sauravtom/4942175 to your computer and use it in GitHub Desktop.
Example of set time interval : Continously print fibonacci numbers on the screen
<!doctype html>
<html lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<title>Sauraxe</title>
<style type="text/css">
#x{
//text-align:center;
font-size:10px;
font-family:‘American Typewriter’, ‘Courier New’, Courier, Monaco, mono;
}
</style>
</head>
<body onload="kickoff();">
<div id="x">0 </div>
<script type="text/javascript">
function $(x){ return document.getElementById(x) };
function random(i,j){ return Math.round(Math.random()*(j-i-1)) + i };
var a = 1;
var b = 1;
var temp;
function randomGen(){
$('x').innerHTML += a + ' ' ;
temp=b;
b=a+b;
a=temp;
console.log(a);
}
function kickoff(){
setInterval(randomGen, 500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment