Cyclops Numbers

Difficulty: ★ ★ ★ ☆

Oh, leave it to the propeller heads to devise a clever and fun name for something the rest of us never pay attention to. This time it’s a cyclops number, which is any decimal integer value with an odd number of digits and a big fat zero in the middle — like a cyclops’ eye.

The digits in a cyclops number need not reflect each other; it isn’t a palindrome number (which apparently is another thing in math). No, it’s just an integer value with an odd number of digits so that it has a center digit. That center digit — and only that digit — must be zero.

Your task for this month’s Exercise is to write code that outputs the first 100 cyclops numbers. Start at zero, even though you need at least a three-digit value to have the first cyclops number. When the code matches the cyclops number pattern, output its value.

Figure 1 shows the output from my solution, where I crafted a fancy table to output the results on a single screen. (I cover the table’s logic in an upcoming Lesson.) You don’t need to output the values in such a table, just a long list is enough.

Table output

Figure 1. Fancy table output showing the first 100 cyclops numbers.

Please try this Exercise on your own before you peek at my solution.

Leave a Reply