Date: 06/21/98 at 08:14:53 From: Catherine Jarman Subject: Happy numbers Do you have any information on happy numbers? A happy number is a positive integer for which the sum of the squares of the digits eventually ends in 1. For example, 13 is happy since 1^2 + 3^2 = 10 and 1^2 + 0^2 = 1.
Date: 06/24/98 at 17:39:58 From: Doctor Hauke Subject: Re: Happy numbers Hi Catherine, 1. Take a number n. 2. Dissect it into digits. 3. Square them all and add them up 4. You get a new number m. 5. If m = 1, n is happy; otherwise set n = m and repeat at 1. 6. If you run into a loop, n is not a happy number. a) Pick a number, as gigantic as you like. b) In the first iteration, it will give maximally the number 9^2+9^2+9^2+... - even a 10-digit number will give a three-digit number after iteration 1. (Can you check that?) c) In the second iteration, all three-digit numbers can turn maximally into 9^2+9^2+9^2 = 243. Nines fatten the result, so the biggest number in the next iteration will be produced by 199, giving 1^2+9^2+9^2 = 163. You have to check these 163 numbers by hand. Of course I'm lazy and wrote a FORTRAN program that said: - only 52 of these numbers don't get smaller in one step - only 22 in two steps - and so on. After five iterations, the computer says only 4 and 5 must be checked further, and there is probably exactly one unhappy loop. I highly recommend trying it on your own :-) - Doctor Hauke, The Math Forum http://mathforum.org/dr.math/
Date: 11/19/98 at 00:38:51 From: Jeremy Subject: A previous Dr. Math question... I don't understand the logic you used here. After the second iteration, your number can still be unbounded. And from what I have found, 4 is not a happy number, which means 2 is not a happy number either. Nor is any number created in the "4-loop," or any number there with zeros, at will, placed between or after the digits. I don't understand your conclusion.
Date: 11/23/98 at 09:56:31 From: Doctor Rob Subject: Re: A previous Dr. Math question... The logic is as follows. You want to find the smallest number on every loop. If any number leads to a smaller number after n steps, it cannot be the smallest number in any loop. (You don't care whether it is on a loop or not.) That way you can eliminate many, many numbers after just a few steps. In particular, numbers n with e digits, that is, with 10^(e-1) <= n < 10^e, lead in one step to numbers at most e*9^2 = 81*e. For e >= 4, this makes them smaller. Thus all numbers with at least 4 digits cannot be the smallest number on a loop. That means that you only have to check numbers smaller than 1000 to see if they are the smallest number in a loop. It also implies that there is at most a finite number of loops. After most of the numbers are eliminated, you can test the rest rather quickly. Then you find that there is the 4-loop 4, 16, 37, 58, 89, 145, 42, 20, 4, and that 5 leads into that loop via 5, 25, 29, 85, 89, .... That is the loop into which all unhappy numbers lead. There is also the 1-loop 1,1, ..., into which all happy numbers lead. - Doctor Rob, The Math Forum http://mathforum.org/dr.math/
Search the Dr. Math Library:
Ask Dr. MathTM
© 1994-2013 The Math Forum