[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

451.0. "Reversing digits and 99, 1089, 9999, ... etc." by KEEPER::KOSTAS () Fri Mar 07 1986 23:50

    Hello,
    
         Reverse the digits of a three figure number and find the
    difference between these two numbers. Then to this difference add
    the result of reversing its digits. Why is the sum always 1089?
    
    For example:
    
       take the number 239
    
         932 - 239 = 693, and  693 _ 396 = 1089
    
    For a two figure number the sum is 99.
    For a three figure number the subm is 1089.
    For a four figure number the sum is 9999.
               
    Enjoy.
    
T.RTitleUserPersonal
Name
DateLines
451.1ULTRA::HERBISONB.J.Sat Mar 08 1986 17:412
        There must be more constraints, for 111 I get a result of 0.
        					B.J.
451.2proof that 0 is correctAVANTI::OSMANEric, Maynard Ma. USA, DTN 223-6664Mon Mar 10 1986 14:0227
    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.39999?LATOUR::JMUNZERMon Mar 10 1986 15:396
    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.4CLT::GILBERTJuggler of NoterdomMon Mar 10 1986 20:2611
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.5correction to .0KEEPER::KOSTASTue Mar 11 1986 00:434
    .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.6LATOUR::JMUNZERTue Mar 11 1986 14:595
    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.7REGINA::LEICHTERJJerry LeichterFri Mar 14 1986 21:3624
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.8CLT::GILBERTJuggler of NoterdomSat Mar 15 1986 02:3513
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.9back to the original problem...CIMAMT::HAINSWORTHMany pages make a thick book.Mon Dec 21 1987 16:1534
    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