The Maths Site
    
HomeForumPuzzlesAudioVideoToolsDonateHistoryContact
Log in here







Forgotten your password?



Or Click to register

iSquared Magazine

The Daily Rant

Puzzles
Counting Palindromes

A palindrome is a word, number, or phrase that reads the same forwards or backwards. For example, the phrases "Madam, I'm Adam" and "Poor Dan is in a droop" are palindromes. The numbers 743347 and 828 are also both palindromes.

Your challenge is to count how many numbers between zero and ten million are palindromes. The first ten are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 (any one digit number reads the same forwards or backwards). But 10 is not a palindrome (even though you could write it as 010, we don't want to allow zero as a leading digit).

Happy counting!

Courtesy of Mark Nielsen

 
Social Bookmarking
Add to: Digg Add to: del.icio.us Add to: StumbleUpon Add to: Google
 
Comments
Login or register to add your comments.
terveloc23:11:40, 17 Nov 07
terveloc's picture
Newbie
Group:Members
Points: 0
Posts: 5
Warn level: 0

I got 10999

public static void main (String [] args)
{
int limit = 10000000;
int count = 0;
String number;

for ( int i = 0 ; i <= limit ; ++i)
{
number = i + "";

if( number.equals(ReverseString.reverseIt(number)))
{
count ++;
}
}
System.out.println("
Final Count: " + count);
}

 
Jackson15:22:46, 13 Oct 07
Jmoney's picture
Newbie
Group:Members
Points: 0
Posts: 2
Warn level: 0

10889

 


© Copyright Andy Drizen 2004-2007 | Website by Think In Colour | Proudly sponsored by JSC Solutions
Valid XHTML 1.0 Transitional Valid CSS!