Last active
August 29, 2015 14:02
-
-
Save ajrob/f7d1a7c6573cba763b55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A palindromic number reads the same both ways. | |
// The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. | |
// Find the largest palindrome made from the product of two 3-digit numbers. | |
var largest = 0; | |
console.log(largestPalindromeByThreeDigits(100, 100)); | |
function largestPalindromeByThreeDigits (j, i) { | |
for (var j = 100; j < 1000; j++){ | |
for (var i = 100; i < 1000; i++) { | |
checkForPalindrome(j*i); | |
} | |
} | |
return largest; | |
} | |
function checkForPalindrome (number) { | |
var flipped = (number).toString().split("").reverse().join("") | |
if (number == flipped && number > largest){ | |
largest = number; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment