3-digit positive decimal (base 10) integers P
, having no leading zeroes and with P
, are such that:
(in this order) are in geometric sequence, and:
are obtained from one another by cyclic permutation
Find all possible triplet(s) (P, Q, R)
that satisfy the given conditions.
: While the solution may be trivial with the aid of a computer program, show how to derive it without one.
It turns out my initial program to solve this had a bug in it, and so did not find any solutions.
Having been disappointed, I wrote a program to find solutions for any permutations, not just cyclic ones. Lo and behold, the solutions found were both cyclic:
432 324 243
864 648 486
DECLARE SUB test (a!, b!, c!)
FOR a = 1 TO 9
FOR b = a TO 9
FOR c = b TO 9
IF a <> b OR b <> c THEN
p(1) = 100 * a + 10 * b + c
p(2) = 100 * b + 10 * c + a
p(3) = 100 * c + 10 * a + b
p(4) = 100 * a + 10 * c + b
p(5) = 100 * b + 10 * a + c
p(6) = 100 * c + 10 * b + a
FOR i = 1 TO 4
FOR j = i + 1 TO 5
FOR k = j + 1 TO 6
test p(i), p(j), p(k)
SUB test (a, b, c)
x = a: y = b: z = c
FOR iter = 1 TO 2
IF x < y THEN SWAP x, y
IF y < z THEN SWAP y, z
IF x * z = y * y THEN PRINT x; y; z
What was the bug in my first program?
It assumed that one of the permutations would have its digits in ascending order. None of the actual solutions is that way, while each has one permutation with digits in descending order. (One and only one of these two possibilities exist for any set of three cyclic permutations of three.)
I disagree, though with Steve Herman's deduction in:
1) Let P = 100a + 10b + c where a,b,c are integers.
In order to be cyclic where P > Q > R.
a>= b > c
What would prevent P from being, say, 413, with Q being 341 and R being 134 (at this stage of the analysis, merely with the information that P>Q>R)? I think, in fact it's analogous to my error, which basically was to assume that R's digits were in ascending sequence, while Steve is saying that P's digits must be in descending sequence.
The observation is that no non-cyclic set of permutations works.
Edited on August 27, 2008, 12:19 pm
Edited on August 27, 2008, 12:31 pm
Posted by Charlie
on 2008-08-27 12:18:46