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

Home > Numbers
Pandigital and Pretty Powerful III (Posted on 2009-05-12) Difficulty: 2 of 5
Determine all possible triplet(s) (P, Q, N) of positive integers, with P < Q and N ≥ 3, such that the decimal representations of PN and QN will together contain each of the digits 0 to 9 exactly once. Neither PN nor QN can contain any leading zero.

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

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Version in Basic Comment 4 of 4 |
Since 2^36 exceeds any 10-digit number we need check no higher n.

Once p^n exceeds a 5-digit number for a given n, we need not check that nor succeeding p, as q is larger and the two powers together will have more than 10 digits.

The following program checks all the possibilities within those constraints:

DEFDBL A-Z
CLS
FOR n = 3 TO 36
  p = 0
  DO
   p = p + 1
   ppwr = INT(p ^ n + .5)
   part1$ = LTRIM$(STR$(ppwr))
   IF LEN(part1$) > 5 THEN EXIT DO
   good = 1
   FOR i = 1 TO LEN(part1$) - 1
      IF INSTR(i + 1, part1$, MID$(part1$, i, 1)) > 0 THEN good = 0: EXIT FOR
   NEXT
   IF good THEN
     q = p
     DO
       q = q + 1
       qpwr = INT(q ^ n + .5)
       part2$ = LTRIM$(STR$(qpwr))
       w$ = part1$ + part2$
       IF LEN(w$) > 10 THEN EXIT DO
       good = 1
       FOR i = 1 TO LEN(w$) - 1
          IF INSTR(i + 1, w$, MID$(w$, i, 1)) > 0 THEN good = 0: EXIT FOR
       NEXT
       IF good AND LEN(w$) = 10 THEN PRINT p, q, n, part1$; " "; part2$
     LOOP
   END IF
  LOOP

NEXT

finding only

21            93            3            9261 804357

meaning (P, Q, N) = (21, 93, 3)
and 21^3 = 9261 and 93^3 = 804357.

  Posted by Charlie on 2009-05-12 15:11:21
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 (11)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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