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