Think Before Counting


Very often a problem situation seems so simple that we plunge right in without first thinking about a strategy to use. This impetuous beginning for the solution often leads to a less elegant solution than one that results from a bit of forethought. Here are two examples of simple problems that can be made even simpler by thinking before working on them.

Find all pairs of prime numbers whose sum equals 999.

Many will begin by taking a list of prime numbers and trying various pairs to see if they obtain 999 for a sum. This is obviously very tedious as well as time consuming.

Think-before-countingLet’s use some logical reasoning to solve this problem. In order to obtain an odd sum for two numbers (prime or otherwise); exactly one of the numbers must be even. Since there is only one even prime, namely 2, there can be only one pair of primes whose sum is 999, and that pair is 2 and 997. That, now, seems so simple.

A second problem where preplanning, or some orderly thinking, makes sense is as follows:

A palindrome is a number that reads the same forward and backward, such as 747 or 1,991. How many palindromes are there between 1 and 1,000 inclusive?

The traditional approach to this problem would be to attempt to write out all the numbers between 1 and 1,000 and then see which ones are palindromes. However, this is a cumbersome and time-consuming task at best, and one could easily omit some of them.

Let’s see if we can look for a pattern to solve the problem in a more direct fashion.

Range
No. of palindromes
Total number

1–9
9
9
10 –99
9
18
100 –199
10
28
200 –299
10
38
300 –399
10
48
.
.
.
.
.
.
.
.
.
There is a pattern. There are exactly 10 palindromes in each group of 100 numbers (after 99). Thus, there will be 9 sets of 10, or 90, plus the 18 from numbers 1 to 99, for a total of 108 palindromes between 1 and 1,000.

Another solution to this problem would involve organizing the data in a favorable way. Consider all the single-digit numbers (self-palindromes), which number 9. The two-digit palindromes (two same digits) also number 9. The three-digit palindromes have 9 possible “outside digits” and 10 possible “middle digits,” so there are 90 of these. In total, there are 108 palindromes between 1 and 1,000, inclusive.

Clever counting can often make work much easier. The motto is: Think first, then begin a solution!


1 comment:

  1. The triangular palindrome can also be expressed in an alternative arrangement as a fraction. Additionally, its denominator can be expressed as a perfect square. Read more here: http://www.glennwestmore.com.au/the-triangular-palindromes-secret/

    ReplyDelete