### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,149)
- misc (2)
- project euler (2)
- puzzle (38)
- site news (44)
- tantalizer (40)
- teaser (3)

### Site Stats

- 175,242 hits

Advertisements

Programming Enigma Puzzles

30 November 2011

Posted by on **From New Scientist #2838, 12th November 2011** [link]

I was surfing the internet recently, and found a reference to polygonal numbers. These are series such as the triangular numbers, pentagonal numbers and others, including the series of heptagonal numbers, which starts 1, 7, 18, 34… I asked my nephew to tell me the next member of this series, which he said was 55. Later he told me that he had found a set of six consecutive heptagonal numbers, all less than two million, where the difference between the first and last was divisible by all of the digits 1 to 9. One of the intermediate heptagonal numbers in this set was divisible by just four of these digits.

What was this heptagonal number?

**Note:** As originally published this Enigma asked for a set of *five* consecutive heptagonal numbers, which admits no solution. The magazine later issued this corrected puzzle.

[enigma1672]

Advertisements

%d bloggers like this:

A quick trip to Wikipedia reveals that for formula for a Heptagonal Number is (5n² – 3n)/2.

You can then make a rolling list of six consecutive heptagonal numbers until you find the ones that satisfy the conditions. This Python program runs in 29ms.

Solution:The intermediate heptagonal number is 409455.The difference between the nth and (n + 5)th heptagonal numbers is 25n + 55, so is always an integer multiple of 5. If n = 9k + 5 it is also a multiple of 9, if 8k + 1 of 8, if 7k + 2 of 7. We don’t then need to check for 1 to 6. n = 401 conforms to all three patterns: the 401st heptagonal number is (interestingly) 401401, the 406th 411481, their difference 10080 = 4×5×7×8×9. I’m still wondering what use heptagonal numbers are!