Project Euler 04. Largest Palindrome Product with F#
Problem Definition
Available at Largest Palindrome Product
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 * 99.Implementation
Find the largest palindrome made from the product of two 3-digit numbers.
We have to find out a palindrome p such that --

where both a and b are three digit number. To do so, we first define a function that checks whether a number (e.g., p) is a palindrome.
[gist]4702943[/gist]
Then, we iterate over all the tuples (a,b) of three digit numbers e.g., [100..999] that satisfy the following equation.

Finally, we check if a*b is a palindrome and get the largest palindrome, as outlined below.
[gist]4703153[/gist]
Would/did you solve it differently? Please let me know your opinion in the comment section below.
Happy problem solving ...

Comments ()