Ken's POTW


Bob's House, and Productive Numbers Revisited
  1. Bob lives on a long street and has noticed that the sum of the house numbers up to his own house, but excluding it, equals the sum of the numbers of his house to the end of the road. If the houses are numbered consecutively, starting from 1, what is the number of Bob's house? Assume there are less than 1000 houses on the road.

  2. Find all numbers i, such that i is equal to the sum of the cubes of its digits.

Source: 1. The Penguin Book of Curious and Interesting Puzzles, David Wells, 1992. 2. Internet newsgroup rec.puzzles.


Solutions: Bill Chapp, Tom Kauffman, Arie Zilberstein, and Wilfred Theunissen found solutions to both problems:
  1. Bob's house could be #3 out of 3, #15 out of 20, #85 out of 119, or #493 out of 696. [The next above 1000 are #2871 out of 4059, and #16731 out of 23660].
    The problem essentially consists of finding k and n such that the sum from 1 to k is half the sum from 1 to n. Bob's house is then k+1. More analysis can break this problem down, but a computer is eventually useful to solve this problem.

    Nick Baxter sent this solution 7/8/98:
    B is Bob's address, N the total number of houses.
    Obviously C(B,2) = C(N+1,2)/2  
    or n^2 + n - 2B(B-1) = 0
    n = (-1+sqrt(8B(B-1)+1))/2
    
    For n to be integer, 8B(B-1)+1 must be a square.
    Let x^2 = 8B^2-8B+1 = 2(2B-1)^2 - 1
    Let M = 2B-1.
    Now we get x^2 - 2M^2 = -1, a Pell equation that can be solved with
    continued fractions, etc. x=1, 7, 41,..., x(i) = 6*x(i-1)-x(i-2).
    and m=5, 29, 169,..., m(i)=6*m(i-1)-m(i-2)
    
    Giving B=3, 15, 85,..., B(i)=6*B(i-1)-B(i-2)-2
    and N=3, 20, 119,..., N(i)=6*N(i-1)-N(i-1)+2
    

    Dave Ellis sent this solution 6/18/97:

    Ken,
    
    I got interested in your "Bob's House" problem from March 26, 1997.  If we
    denote the series as 1,2,3, ... p-1, p, ... q, then using the formula for the
    sum of q terms in an AP we get:
    
            2p(p-1) - q(q+1) = 0.
    
    This makes a simple search condition.  To make any search reasonably fast, the
    range must be severely restricted for larger numbers.  Rearranging the above
    equation and solving the resultant quadrtic yields:
    
            p = (1 + sqrt(1 + 2q(q-1)))/2.
    
    Using this equation, for each q  we need only search 2 numbers, the integers
    below and above p.  The following code does just that:
    
    /* Bob's House solution, by Dave Ellis */
    
    #include 
    #include 
    #include 
    
    unsigned long r;
    double p, q;
    
    void main(void)
    { clrscr();
      for (q=2; q < pow10(8); q++)
      { r = (1+sqrt(1+2*q*(q-1)))/2;
        for (p=r; p < r+2; p++)
          if (2*p*(p-1)-q*(q+1)==0)
            printf("%8.0f %8.0f\n",p, q);
      }
    }
    
    Here are the results, which go a little beyond those you published:
    
    p         q
    3         3
    15        20
    85        119
    493       696
    2871      4059
    16731     23660
    97513     137903
    568345    803760
    3312555   4684659
    19306983  27304196
    
    The interesting thing is that, as the numbers get bigger, two trends emerge:
    
    1.  For both p and q the ratio of any number to its predecessor tends toward
    5.8284, reaching it more quickly for p than q, but getting there in only a few
    terms in either case.
    
    2.  The ratio of q to p tends toward root 2.
    

    Denis Borris sent the following analysis on 7/27/98 [a good day - KD]:

    The nth Bob's address and "end of the road" address can
    be directly calculated.
    
    Let Bob's address = P + 1 and last address = Q.
    
    Using sums of consecutive numbers [1 to P] and [P+1 to Q],
    we get Q(Q+1) = 2P(P+1); re-write to get
    
              (2Q+1)^2 - 2(2P+1)^2  =  -1
    
    which is a Pell equation, general form: x^2 - Dy^2  =  +-1
    (D being a non-square integer)
    
    Using this equation (sites dealing with solving the Pell equation
    are all over the place, so I won't show any interim calculations)
    leads to this formula:
    
    Bob's address:
    P(n) = 1 + (A*G^n + B*H^n - 1) / 2
    where:
    G = 3 + 2sqr(2)    , H = 3 - 2sqr(2)
    A = (2 + sqr(2))/4 , B = (2 - sqr(2))/4
    
    Last address:
    Q(n) = (A*G^n + B*H^n - 1) / 2
    where:
    G = 3 + 2sqr(2)    , H = 3 - 2sqr(2)
    A = (1 + sqr(2))/2 , B = (1 - sqr(2))/2
    
    Here's the 1st 15: 
        N               P                Q
        1               3                3
        2              15               20
        3              85              119
        4             493              696
        5            2871             4059
        6           16731            23660
        7           97513           137903
        8          568345           803760
        9         3312555          4684659
       10        19306983         27304196
       11       112529340        159140519
       12       655869060        927538919
       13      3822685022       5406093002
       14     22280241074      31509019099
       15    129858761424     183648021598
    
    [wonder if Johnny Pell knew his equation would be used
     for such an illustrious purpose as house numbers...]
    
    I sent my stuff to Nick Baxter for scrutiny;
    he returned this amazingly compact formula:
    (makes mine look like the work of a lumberjack)
    
    p(n) = ((2+s)(3+s)^n - (2-s)(3-s)^n + 2s)/4s
    q(n) = ((2+s)(3+s)^n + (2-s)(3-s)^n - 4)/8
    where s = sqrt(8)
    ...what a piece of art!
    

  2. The possible numbers are: 0, 1, 153, 370, 371, 407. I assume that all submitters used a computer to find the solutions. One other solution (that wasn't submitted) which could be a legitimate answer is -1, but it depends if you allow a digit to be considered negative; i.e. which digit(s) would be negative in a multi-digit negative number?

    Arie Zilberstein admitted to using a program to solving this problem but found the answers to be: 0, 1, 1634, 8208, 9474. I believe he actually solved the Productive Numbers ReRevisited problem.


Mail to Ken