All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Digital power (Posted on 2008-11-15) Difficulty: 2 of 5
Find all numbers N = a1a2a3...an greater than 1, with no leading zeros, no zeros, which fits this equation:

N = a1a1 + a2a2 + a3a3 + ... + anan

Clarifying, N = 23 doesn´t work because 22 + 33 is equal to 31, not 23.

See The Solution Submitted by pcbouhid    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 6

The number N can have no more than 10 digits, as

9^9 = 387,420,489

so that even 11 repetitions of 9 would result in only a 10-digit number.

The following program checks the sums of all combinations from 1 to 10 digits and sees if the total has the same set of digits. If that's the case, then the total is the given number:

DEFDBL A-Z
DECLARE SUB tackOn ()
DIM SHARED v(9), n$, tot

FOR i = 1 TO 9
  v(i) = i ^ i
NEXT

tackOn

END

DEFDBL A-Z
SUB tackOn
 IF LEN(n$) = 0 THEN st = 1:  ELSE st = VAL(RIGHT$(n$, 1))
 FOR dig = st TO 9
  tot = tot + v(dig)
  n$ = n$ + LTRIM$(STR$(dig))

  t$ = LTRIM$(STR$(tot))
  DO
    done = 1
    FOR i = 1 TO LEN(t$) - 1
      IF MID$(t$, i, 1) > MID$(t$, i + 1, 1) THEN
        h$ = MID$(t$, i, 1)
        MID$(t$, i, 1) = MID$(t$, i + 1, 1): MID$(t$, i + 1, 1) = h$
        done = 0
      END IF
    NEXT i
  LOOP UNTIL done
  IF t$ = n$ THEN
    PRINT tot
  END IF
  IF LEN(n$) < 10 THEN tackOn

  n$ = LEFT$(n$, LEN(n$) - 1)
  tot = tot - v(dig)
 NEXT dig
END SUB

Only 92,377 combinations of digits had to be checked this way, rather than all 1- through 10-digit numbers.

the results were

1
3435

as, when the program was checking out 3,3,4,5 and the total came out to 3435, it recognized that the digits were the same but in a different order, and printed the total.

So 3435 is the only other number aside from 1 fitting the criteria.


  Posted by Charlie on 2008-11-15 16:44:23
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (2)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information