Code difficulty: 5/10
Math difficulty: 4/10

Before we begin here: Q. What is a palindrome?
A. A Palindrome is a number that is repeated both backwards and forwards

In his challenge I ask that you do the following things:

Create a program that will:

  1. Iterate up to 1 million (1,000,000 or 1.000.000 for those of you that use . instead of ,)
  2. Check each number to see if it is a palindrome
  3. Count how many palindromes there are between 1 and 1 million, count how many of these palindromes are prime
  4. Store each number that is both a palindrome and a prime number and output them at the end of the loop
  5. Program to try to reduce runtime efficiency (hint: Your prime loop will likely take the most resources)

Concepts used: Functions, variables, loops, arithmatic functions, breaks, boolean, vectors (or lists), template class member functions

You should be able to do this by: Lesson 44 with some help from this example

My solution:
Note This solution has been reduced to 1000, you can change the number in the loop.
Note: This solution contains spoilers.

Please note that my solutions are not checked thoroughly, and should only be used for reference. They are often non-optimal solutions that could be improved upon (by you!). I keep these intentionally rough for just that reason.

Last modified: October 14, 2013