# Enigmatic Code

Programming Enigma Puzzles

## Enigma 1231: A little list

From New Scientist #2387, 22nd March 2003 [link]

Here is a list of properties which a number may or may not have.

1. Several numbers divide into it exactly, but only one of them is prime.
2. It can be written as the sum of two or more consecutive positive integers.
3. It has more than two digits.
4. It is prime.
5. It is over 10000.
6. It is a perfect square.

You can choose any number and write down (in order) the numbers of the statements which are true. For example for the number 135 you would get statements 2 and 3 only, which written as one number gives 23.

There is just one number for which the list of true statements gives the number itself.

Which number?

[enigma1231]

### One response to “Enigma 1231: A little list”

1. Jim Randell 23 May 2015 at 8:30 am

Recently I added the prime_factor() routine to enigma.py, which generates the (prime, exponent) pairs in the prime factorisation of a positive integer. This puzzle provides a good opportunity to use it.

This Python code runs in 32ms.

```from enigma import subseqs, nconcat, prime_factor, printf

# return the numbers of the statements which are true
def statements(n):

# list of (prime, exponent) factors of n
fs = list(prime_factor(n))

# 1. "several numbers divide into it exactly, but only one of them is prime"
# so it is a prime power, the power being at least 2
if len(fs) == 1 and fs[0][1] > 1: yield 1

# 2. "it can be written as the sum of two or more consecutive integers"
# i.e. it is a polite number, so not an exact power of 2
if n > 1 and not(len(fs) == 1 and fs[0][0] == 2): yield 2

# 3. "it has more than 2 digits"
if n > 99: yield 3

# 4. "it is prime"
if len(fs) == 1 and fs[0][1] == 1: yield 4

# 5. "is is over 10000"
if n > 10000: yield 5

# 6. "it is a perfect square"
if all(e % 2 == 0 for (p, e) in fs): yield 6

# consider (non-empty) subsequences
for ns in subseqs((1, 2, 3, 4, 5, 6), min_size=1):
# turn the subsequence into a number
n = nconcat(ns)
# are the true statements the same as the subsequence?
if ns == tuple(statements(n)):
printf("n={n}")
```

Solution: The number is 16.