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

Home > Numbers
Powers of the Digits (Posted on 2023-08-18) Difficulty: 3 of 5
Let N be an integer expressed in decimal.
Let D(N) be the sum of the digits of N expressed in decimal.
Let S(N) be the sum of the squares of the digits of N expressed in decimal.
Let C(N) be the sum of the cubes of the digits of N expressed in decimal.

Find the smallest pandigital number N (that is, containing all of the digits 0 to 9) which contains D(N), S(N) and C(N).

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 Solution | Comment 1 of 2
I found 125843706679.

For any 10-digit pandigital, d(n), s(n), c(n) will always be [45, 285, 2025], but this can't be a 10 digit pandigital due to multiple appearances of several digits

For an 11-digit pandigital, there are 10 possibilities for each function:
[45, 285, 2025] if 0 is the digit that appears twice
[46, 286, 2026] if 1 is the digit that appears twice
[47, 289, 2033] if 2 is the digit that appears twice
[48, 294, 2052] etc
[49, 301, 2089] ...
[50, 310, 2150]
[51, 321, 2241]
[52, 334, 2368]
[53, 349, 2537]
[54, 366, 2754] if 9 is the digit that appears twice

But a quick review of those 10 triplets shows that each has too many of some digit.

For a 12-digit pandigital, there are 55 options for the 2 extra digits.
The program below produces a list of each of those, identified by the 2 extra digits and the triplet of sum of digits, squares, cubes of digits.
I had not yet worked out an algorithm for checking these for inconsistencies, so I scanned the 55 visually and found only one that works:

extra digits; [SOD, SOS, SOC]
[[6, 7], [58, 370, 2584]]
The sum of digits is included in the sum of cubes of digits.
2584
370
Digits not yet used:  16679 

My Solution:  125843706679

The program below will accept any number of digits, as the digits go from 11, 12, 13 etc, the possibilities go from:  10, 55, 220, 715, 2002   So if I did not find a 12-digit pandigital, I would have needed to come up with an algorithm to weed out those that have superfluous digits.  Weeding out some would be easy, but non-trivial to weed out all.

-------------
a = 0
b = 0
c = 0
trip10 = [0,0,0]
for i in range(10):
    trip10[0] += i
    trip10[1] += i**2
    trip10[2] += i**3

sods = []
soss = []
socs = []
triplets = []

digits = '0123456789'
digs = [int(a) for a in digits]
from itertools import combinations_with_replacement
ndigits = 12
extra = ndigits - 10
allints = []
for comb in combinations_with_replacement(digits, extra):
    ints = [int(c) for c in comb ]
    allints.append(ints)
    trip = trip10[:]
    for i in ints:
        trip[0] += i
        trip[1] += i**2
        trip[2] += i**3
    triplets.append([ints,trip])

for t in triplets:
    print(t)

-------   triplets for n = 12
[[0, 0], [45, 285, 2025]]
[[0, 1], [46, 286, 2026]]
[[0, 2], [47, 289, 2033]]
[[0, 3], [48, 294, 2052]]
[[0, 4], [49, 301, 2089]]
[[0, 5], [50, 310, 2150]]
[[0, 6], [51, 321, 2241]]
[[0, 7], [52, 334, 2368]]
[[0, 8], [53, 349, 2537]]
[[0, 9], [54, 366, 2754]]
[[1, 1], [47, 287, 2027]]
[[1, 2], [48, 290, 2034]]
[[1, 3], [49, 295, 2053]]
[[1, 4], [50, 302, 2090]]
[[1, 5], [51, 311, 2151]]
[[1, 6], [52, 322, 2242]]
[[1, 7], [53, 335, 2369]]
[[1, 8], [54, 350, 2538]]
[[1, 9], [55, 367, 2755]]
[[2, 2], [49, 293, 2041]]
[[2, 3], [50, 298, 2060]]
[[2, 4], [51, 305, 2097]]
[[2, 5], [52, 314, 2158]]
[[2, 6], [53, 325, 2249]]
[[2, 7], [54, 338, 2376]]
[[2, 8], [55, 353, 2545]]
[[2, 9], [56, 370, 2762]]
[[3, 3], [51, 303, 2079]]
[[3, 4], [52, 310, 2116]]
[[3, 5], [53, 319, 2177]]
[[3, 6], [54, 330, 2268]]
[[3, 7], [55, 343, 2395]]
[[3, 8], [56, 358, 2564]]
[[3, 9], [57, 375, 2781]]
[[4, 4], [53, 317, 2153]]
[[4, 5], [54, 326, 2214]]
[[4, 6], [55, 337, 2305]]
[[4, 7], [56, 350, 2432]]
[[4, 8], [57, 365, 2601]]
[[4, 9], [58, 382, 2818]]
[[5, 5], [55, 335, 2275]]
[[5, 6], [56, 346, 2366]]
[[5, 7], [57, 359, 2493]]
[[5, 8], [58, 374, 2662]]
[[5, 9], [59, 391, 2879]]
[[6, 6], [57, 357, 2457]]
[[6, 7], [58, 370, 2584]]
[[6, 8], [59, 385, 2753]]
[[6, 9], [60, 402, 2970]]
[[7, 7], [59, 383, 2711]]
[[7, 8], [60, 398, 2880]]
[[7, 9], [61, 415, 3097]]
[[8, 8], [61, 413, 3049]]
[[8, 9], [62, 430, 3266]]
[[9, 9], [63, 447, 3483]]

Edited on August 18, 2023, 12:05 pm
  Posted by Larry on 2023-08-18 12:02:45

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 (8)
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