Quotes help make search much faster. Example: "Practice Makes Perfect"

Monday, February 4, 2013

Math Problems: Finding a Product


Script solution for finding a product problem:

Answer: 30

console.log("----------------------------------");
function somfun(a,b,c){
var num = ((a*b)-1)*((b*c)-1)*((c*a)-1);
var den = a*b*c;
if(num % den === 0){
return true;
} else {
return false;
}
}

var max=100;
for(var i=2; i<=max; i++){
for(var j=2; j<=max; j++){
for(var k=2; k<=max; k++){
if(somfun(i,j,k)){
var temp = i*j*k;
console.log(i+" "+j+" "+k+" "+temp);
}
}
}
}

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts