vendredi 3 juin 2016

can't enter the IF statement

I'm trying to solve the Project Euler Problem on the largest palindrome product in Javascript and I don't understand why the program doesn't enter the IF statement:

(function palyndrom(max, min) {
    
    top: 
    for (i = max; i > min; i--) {
        for (c = max; c > min; c--) {
            if(i*c == c*i) {
                alert('same was before');
            }
            
            else {
                var number = i*c;
                console.log('i*c = ' + i + '*' + c + ' = ' + number); 
    
                if (number.toString() == number.toString().split('').reverse().join('')) {
                    alert('PALYNDROM FOUND: i*c = ' + i + '*' + c + ' = ' + number);
                    break top;
                }   
            }
        }
    
})(999, 900);

Aucun commentaire:

Enregistrer un commentaire