算法练习--ABCD*E=DCBA
//1.ABCD * E = DBCA
//2.A,B,C,D {0-9} , E {1-9}
//3.A,B,C,D,E all different
var existSameN = function (arr){ for(var i = 0; i < arr.length; i++){ for(var j = 0; j < arr.length ; j++){ if(j == i){continue;} if(arr[i] == arr[j]) {return true;} } } return false; } var ret = new Array(); for(var i = 1000; i< 9999; i++){ var strI = i.toString(); var arr = new Array(strI[0],strI[1],strI[2],strI[3]); if(existSameN(arr)){continue;} var reverseI = parseInt(strI[3] + strI[2]+strI[1]+strI[0]); for(var j = 1; j<= 9 ; j++){if(i * j == reverseI) {ret.push( {num:i,mul:j});}} } for(var i = 0;i < ret.length; i++) console.log("number : " + ret[i].num + ", multiply by : " + ret[i].mul);