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

Sunday, January 27, 2013

Math Problems: 5-digit Palindromes


Question:

How many five digit palindromes are there?

Answer: 900

Solution: Solved using the script below


console.log("*********************************");
var count=0;
for(var i=0; i<100000; i++){
if(i>=10000){
var temp = i.toString();
if(temp.charAt(0)===temp.charAt(4) && temp.charAt(1)===temp.charAt(3)){
console.log(temp);
count++;
}
}
}
console.log("Count is "+count);

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts