### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

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

### Site Stats

- 177,972 hits

Advertisements

Programming Enigma Puzzles

31 January 2012

Posted by on **From New Scientist #2747, 13th February 2010** [link]

Joe thought he would test Penny’s ability to manipulate equations this week. So he asked her to find the values of the integers A, B and C in the following equation.

(A.B + 1) ÷ (A.B.C + A + C) = 0.138

What are the values of A, B and C?

**Note:** If it’s not obvious this is a division: ((A×B) + 1) / ((A×B×C) + A + C) = 0.138

[enigma1582]

Advertisements

%d bloggers like this:

It’s easy to find

asolution to this problem without programming.The equation can be rewritten as:

Clearly

(AB + 1)cannot be zero (as it is the numerator for a non-zero fraction), so we can rewrite the equation as:At this point we can equate the integer and fractional parts and it is easy to see a solution:

But is it the only solution?

If we consider the case where A and B are both positive integers, then it is clear than

0 < (A / (AB + 1)) < 1, so C can only be 7, leaving:So suppose: A = 17n and AB + 1 = 69n for some positive integer n. Substituting for A we get, 17nB + 1 = 69n, which rewriting for n gives:

Which can only have an integer solution of n=1, when 69 – 17B = 1, i.e. B = 68/17 = 4.

So it is indeed the only solution where A, B are positive integers.

Also A cannot be zero. If it is the original equation reduces to: 1/C = 69/500, and if B is zero the equation reduces to 1/(A+C) = 69/500, both of which are impossible to satisfy.

You can then consider the cases where, (A, B < 0), (A > 0), (B > 0) by rewriting the equation in terms of positive -a and -b, as necessary and following reasoning similar to that above to show that no further integer solutions are possible.

Solution:A=17, B=4, C=7.Here’s a programmatic solution. It tests integer triples (A, B, C) until it finds a solution. It runs in 88ms.

This means I can remove the puzzle from my list of Enigmas that I have not solved programatically.