<!DOCTYPE html public "-//W3C//DTD XHTML 1.0 Strict //EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>求一个由1-9组成的各位不同的九位数,从第二位开始前N位数可以被N整除</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script type="text/javascript">
<!--
function findTheIntege(){
var maxInt = 987654321;
var minInt = 123456789;
var aimInt = 0;
var count = 0;
while(maxInt>=minInt){
var intArray = spliceIntege(maxInt);
for(var n=8; n>1; n--){
for(var i=0; i<n; i++){
aimInt = 10*aimInt + intArray[7-i];
}
if(aimInt%n == 0){
count += 1;
}
}
if(count == 7){
document.getElementById("rels").innerHTML = aimInt;
}
maxInt--;
}
}
function spliceIntege(the_int){
var intArray = new Array();
for(var i=0; i<9; i++){
intArray[i] = the_int%10;
the_int = Math.floor(the_int/10);
}
return intArray;
}
//-->
</script>
</head>
<body>
<input type="button" value="find"
onClick="findTheIntege();" /><br/>
<div id="rels">Searching...</div>
</body>
</html>