A positive integer is called shiny if it can be written as the sum of two not necessarily distinct integers a and b which have the same sum of their digits. For instance, 2012 is shiny, because 2012 = 2005 + 7, and both 2005 and 7 have the same sum of their digits. Find all positive integers which are not shiny (the dark integers).
FOR n = 1 TO 99999999
shiny = 0
FOR a = 1 TO n / 2
b = n  a
IF sod(a) = sod(b) THEN shiny = 1: EXIT FOR
NEXT
IF shiny = 0 THEN PRINT n
NEXT
FUNCTION sod (x)
t = 0
s$ = LTRIM$(STR$(x))
FOR i = 1 TO LEN(s$)
t = t + VAL(MID$(s$, i, 1))
NEXT
sod=t
END FUNCTION
finds
1
3
5
7
9
29
49
69
89
199
399
599
799
999
2999
4999
6999
8999
19999
39999
59999
79999
99999
...
etc. (program stopped manually at this point)
It would seem that an even number (including zero) of 9's prefaced by an odd digit, or an odd number of 9's prefaced by an even digit, constitute the representations of such "dark numbers".

Posted by Charlie
on 20130621 01:22:27 