< Previous | Next | Content >

## Search for Palindrome

The following puzzle is taken from Great Critical Thinking Puzzles by Michael A. DiSpezio (1997).

While driving his car, BOB observes that the odometer reading forms a palindrome of 13931 km. Bob keep driving and two hours later he looks at the odometer again and to his surprise, it display different palindrome. What is the most likely the speed that Bob is traveling?

To answer the puzzle above, you need the following code to search for the next palindrome number.

We can modify the code to generate palindrome number into a code to search the next palindrome number. Basically we iterate the number from the minimum to the maximum values and test whether that number is a palindrome . Unlike palindrome generation , we stop the iteration once we can find the first palindrome.

Function SearchNextPalindromeNumber(minNum, maxNum) ' return the next palindrome number. Search between minimum number and maximum number ' (c) 2011 Kardi Teknomo ' http://people.revoledu.com/kardi/ For i = minNum + 1 To maxNum If isPalindrome(CStr(i)) Then SearchNextPalindromeNumber=i Exit For End If Next i End Function

Using the code to search next palindrome above, try to answer the following questions:

• Are there any two consecutive palindromes whose multiplication is also a palindrome?
• Are there any two consecutive palindromes whose difference is also a palindrome?
• Are there any two consecutive palindromes whose summation is also a palindrome?

< Previous | Next | Content >

Preferable reference for this tutorial is

Teknomo, Kardi. (2012) Palindrome. http://people.revoledu.com/kardi/tutorial/Palindrome/