|
|
A007532
|
|
Handsome numbers: sum of positive powers of its digits; a(n) = Sum_{i=1..k} d[i]^e[i] where d[1..k] are the decimal digits of a(n), e[i] > 0.
(Formerly M0487)
|
|
15
|
|
|
1, 2, 3, 4, 5, 6, 7, 8, 9, 24, 43, 63, 89, 132, 135, 153, 175, 209, 224, 226, 262, 264, 267, 283, 332, 333, 334, 357, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 407, 445, 463, 518, 598, 629, 739, 794, 849, 935, 994, 1034
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
COMMENTS
|
J. Randle has suggested the name "powerful numbers" for the perfect digital invariants A023052, equal to the sum of a fixed power of the digits. However, "powerful" usually refers to a prime factorization related property, cf. A001694 (and references there as well as on the MathWorld page). C. Rivera has suggested the name "handsome" for these numbers (in view of narcissistic numbers A005188) in his prime puzzle #15: see also contributed comments concerning terminology on that page. - M. F. Hasler, Nov 21 2019
|
|
REFERENCES
|
N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
|
|
LINKS
|
|
|
FORMULA
|
If n = d_1 d_2 ... d_k in decimal, then there are integers m_1, m_2, ..., m_k > 0 such that n = d_1^m_1 + ... + d_k^m_k.
|
|
EXAMPLE
|
43 = 4^2 + 3^3 is OK; 254 = 2^7 + 5^3 + 4^0 is not OK since one of the powers is 0.
|
|
MAPLE
|
N:= 10000; # to get all entries <= N
Sums:= proc(L, N)
option remember;
local x1, L1;
x1:= L[1];
if x1 = 1 then L1:= {1}
else L1:= {seq(x1^j, j=1..floor(log[x1](N)))};
fi;
if nops(L) = 1 then L1
else select(`<=`, {seq(seq(a+b, a=L1), b=Sums(L[2..-1], N))}, N)
fi
end proc;
filter:= proc(x, N)
local L;
L:= sort(subs(0=NULL, convert(x, base, 10))) ;
member(x, Sums(L, N));
end proc;
|
|
MATHEMATICA
|
Select[Range@1000, (s=#; MemberQ[Total/@(a^#&/@Tuples[Range@If[#==1||#==0, 1, Floor[Log[#, s]]]&/@(a=IntegerDigits[s])]), s])&] (* Giorgos Kalogeropoulos, Aug 18 2021 *)
|
|
PROG
|
(Haskell)
a007532 n = a007532_list !! (n-1)
a007532_list = filter f [1..] where
f x = g x 0 where
g 0 v = v == x
g u v = if d <= 1 then g u' (v + d) else v <= x && h d
where h p = p <= x && (g u' (v + p) || h (p * d))
(u', d) = divMod u 10
(Python)
from itertools import count, takewhile
def cands(n, d):
return takewhile(lambda x: x<=n, (d**i for i in count(1)))
def handsome(s, t):
if s == "":
return t == 0
if s[0] in "01":
return handsome(s[1:], t - int(s[0]))
return any(handsome(s[1:], t - p) for p in cands(t, int(s[0])))
def ok(n):
return n and handsome(str(n), n)
|
|
CROSSREFS
|
|
|
KEYWORD
|
base,nonn,nice
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|