When you give the program a seed and max it goes through every number and divides it by 2 and 3 and displays the remainder. I want it to give a second between the time it solves it, to the next one. But whenever I try to use a setInterval
it freezes and crashes even on 2 different editors. I also have another problem because when you enter a seed and max into the input boxes it wont save the numbers and it uses the ones from the javascript and not the input box. Thanks in advance, I am 11 and started programming a few months ago.
Here is what I have so far:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Made with Thimble</title>
<link rel="stylesheet" >
</head>
<body bgcolor="lightblue">
<div id="d2">
Divisible by 2
</div>
<div id="d3">
Divisible by 3
</div>
<div>
<input id="seed" type="number" placeholder="seed" value="3"><br>
<input id="max" type="number" placeholder="max" value="8">
</div>
<button onclick="count()">Count</button>
<div id="output"></div>
<script>
function count(){
var seed= document.getElementById("seed").getAttribute("value")
var max=document.getElementById("max").getAttribute("value")
var temp=1
var output=document.getElementById("output")
temp=seed
console.log("seed:"+seed)
console.log("max:"+max)
while (temp<max){
var intdivby2 = temp%2
var intdivby3 = temp%3
document.getElementById("output").innerHTML+="remainder of "+temp+" divided
by 2 is:"+intdivby2.toString()+"<br>"
document.getElementById("output").innerHTML+="remainder of "+temp+" divided
by 3 is:"+intdivby3.toString()+"<br>"
setInterval(function(){temp++;},1)
}
}
</script>
</body>
</html>