Created
December 31, 2017 11:24
-
-
Save taka2/764febc175b576b9f67a7abc50ce7007 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript"> | |
function btn1_onClick() { | |
// step 0 | |
var output = document.getElementById("output"); | |
output.innerHTML = ""; | |
// step 1 | |
a = parseInt(form1.a.value); | |
while(true) { | |
// step 2 | |
b = parseInt(Math.sqrt(a)); | |
// step 3 | |
if(b <= 1) { | |
return; | |
} | |
// step 4 | |
// document.writeln("b = " + b); | |
//alert("b = " + b); | |
output.innerHTML+="</br>b = " + b; | |
// step 5 | |
a = a - (b * b); | |
// step 6 | |
if(a < 1) { | |
return; | |
} | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<form name="form1"> | |
<button type="button" name="btn1" value="btn1" onClick="btn1_onClick()"> | |
button | |
</button> | |
<input type="text" name="a"></input> | |
</form> | |
<div id="output"/> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment