T.R | Title | User | Personal Name | Date | Lines |
---|
451.1 | | ULTRA::HERBISON | B.J. | Sat Mar 08 1986 14:41 | 2 |
| There must be more constraints, for 111 I get a result of 0.
B.J.
|
451.2 | proof that 0 is correct | AVANTI::OSMAN | Eric, Maynard Ma. USA, DTN 223-6664 | Mon Mar 10 1986 11:02 | 27 |
| Any three-digit number can be regarded as:
a*100 + b*10 + c*1
So, to subtract the reversal, we have
a*100 + b*10 + c*1 - (c*100 + b*10 + a*1)
which is
(a-c)*100 + 0*10 + (c-a)*1
Now we're asked to add to this its own reversal, so we form
(a-c)*100 + 0*10 + (c-a)*1 + (c-a)*100 + 0*10 + (a-c)*1
which is
(a-c+c-a)*100 + 0*10 + 0*10 + (c-a+a-c)*1
which boils down to a thick
0.
So yes, I agree with what you said about 111.
/Eric
|
451.3 | 9999? | LATOUR::JMUNZER | | Mon Mar 10 1986 12:39 | 6 |
| Seems to work okay for (abc - cba), if a > c.
But four digits and 9999? 8642 - 2468 = 6174, and 6174 + 4716 =
10890 (a frequent result).
John
|
451.4 | | CLT::GILBERT | Juggler of Noterdom | Mon Mar 10 1986 17:26 | 11 |
| re .0
At one point, you have the quantity:
(a-c)*100 + 0*10 + (c-a)*1
and assume that the value of this value digit-reversed is:
(c-a)*100 + 0*10 + (a-c)*1
This is NOT generally true when a and c are unequal.
If 0 < a-c < 10, the sum *is* 1089.
|
451.5 | correction to .0 | KEEPER::KOSTAS | | Mon Mar 10 1986 21:43 | 4 |
| .3 is correct when saying that for four digit numbers the result
is 10890 and not 9999 as it was given in .0
Thanks John.
|
451.6 | | LATOUR::JMUNZER | | Tue Mar 11 1986 11:59 | 5 |
| But 9999 is right (sometimes) also, and I think there are two more
answers, all starting with four digit numbers that are greater than
their reverses.
John
|
451.7 | | REGINA::LEICHTERJ | Jerry Leichter | Fri Mar 14 1986 18:36 | 24 |
| The classic problem of this form is a little different: Start with any
4-digit number containing at least 2 distinct digits; you can have leading 0's
as well (they'll arise in later steps). For such an N, compute T(N) by: Sort
N's digits in ascending order; subtract the result of sorting N in descending
order. Iterating T converges to 6174, which is a fixed point, after something
like 6 steps at most.
This can be proved without trying all combinations, though the proofs I've
seen still come down to elaborate case analysees. They provide no insight
into the general problem of applying T to k-digit numbers in base n, for
arbitrary k and n. Obviously, you always eventually converge to some cycle.
When is there a unique cycle, independent of starting point? When is the
unique cycle of length 1? The only unique, length 1 solutions I found were in
based 5 and 10, for small values of k.
Hint for computation: T(m) is divisible by (n-1) for all m (in base n). (The
proof is trivial.) Hence, one might as well only examine number divisible by
(n-1). Further, it's pretty easy to generate such numbers with digits already
in non-increasing order (use the fact that a number is divisible by (n-1) iff
the sum of its digits is divisible by (n-1) - same proof!) This greatly
reduces the size of your search (and brings up the combinatorial question:
How many k-digit numbers are there in base n that are divisible by (n-1) and
have their digits in non-increasing order?)
-- Jerry
|
451.8 | | CLT::GILBERT | Juggler of Noterdom | Fri Mar 14 1986 23:35 | 13 |
| re: the sorted reversal problem
When dealing with 7-digit numbers, T(n) is always of the form:
i * 999999 + j * 99990 + k * 9900, 9 >= i >= j >= k >= 0
This substantially reduces the search space.
I noticed that for 7-digit numbers, many (most/all?) cycle with period 8
(I did not check whether these fall into the same cycle). The trivial
case of 0000000 cycles with period 1, and we'll ignore 0 henceforth.
The last paragraph in .-1 is helpful *only* if you're looking for a 1-cycle.
|
451.9 | back to the original problem... | CIMAMT::HAINSWORTH | Many pages make a thick book. | Mon Dec 21 1987 13:15 | 34 |
| re: the original problem:
Given a 3 digit number abc. 0 <= a,b,c <= 9.
If a=c, the sum is 0. If a<c, the result is -1089. If a>c, the
result can be computed as follows:
original # 100a + 10b + c
reversed number a + 10b + 100c
----------------------
difference 99a - 99c = 99(a-c)
= 100(a-c) - (a-c)
1 <= a-c <= 9.
thus -9 <= c-a <= -1.
using this information, I can do the carries on the above difference:
difference 100(a-c-1) + 10 (9) + 1 (10 - (a-c))
remember, this is still equal to 99(c-a)
reversing its digits gives
reversed difference (a-c-1) + 10 (9) + 100 (10 - (a-c))
= (a-c) + 1 + 90 + 1000 - 100(a-c)
= 1089 - 99(a-c)
adding the difference to the reversed difference gives:
d + rd = 99(a-c) + 1089 - 99(a-c) = 1089.
So the 1089 came out of the carries in the subtraction.
John
|