Skip to content

Instantly share code, notes, and snippets.

@dolpen
Created October 29, 2010 19:51
Show Gist options
  • Save dolpen/654267 to your computer and use it in GitHub Desktop.
Save dolpen/654267 to your computer and use it in GitHub Desktop.
<html>
<head>
<script type="text/javascript">
<!--
var $=function(n){
return document.getElementById(n);
};
var a=function(str){
if(str.length!=8)return "死";
for(i=1;i<=8;i++)if(str.indexOf((i).toString(),0)<0)return "死";
for(i=2;i<=8;i++)if(parseInt(str.substr(0,i))%i!=0)return "死";
return "正解";
};
window.onload=function(){
$("btn").onclick=function(){
alert(a($("number").value));
};
};
//-->
</script>
</head>
<body>
<p>1,2,3,4,5,6,7,8を1つずつ使って、以下の条件を満たす8桁の数値abcdefghを答えよ。</p>
<ul>
<li>2桁の数値abは2で割り切れる</li>
<li>3桁の数値abcは3で割り切れる</li>
<li>4桁の数値abcdは4で割り切れる</li>
<li>5桁の数値abcdeは5で割り切れる</li>
<li>6桁の数値abcdefは6で割り切れる</li>
<li>7桁の数値abcdefgは7で割り切れる</li>
<li>8桁の数値abcdefghは8で割り切れる</li>
</ul>
<p style="font-size:x-small">abなどの表記は、ここではabの積ではなくそれぞれの文字に数字が1つ入った複数桁の数値とする。</p>
<p>
<input type="text" size="8" id="number" />
<input type="button" size="8" id="btn" value="答える"/>
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment