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.
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
Offset: 1
Examples
43 = 4^2 + 3^3 is OK; 254 = 2^7 + 5^3 + 4^0 is not OK since one of the powers is 0.
References
- N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
Links
- David W. Wilson, Table of n, a(n) for n = 1..10000
- Giovanni Resta, d-powerful numbers, the 30067 terms and sums up to 10^6.
- Carlos Rivera, Puzzle 15.- Narcissistic and Handsome Primes, The Prime Puzzles and Problems Connection.
- Eric Weisstein's World of Mathematics, Powerful Number.
- Index entries for sequences related to powerful numbers
Crossrefs
Programs
-
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 -- Reinhard Zumkeller, Jun 02 2013
-
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; A007532:= select(filter,[$1..N],N); # Robert Israel, Apr 13 2014
-
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 *)
-
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) print(list(filter(ok, range(1035)))) # Michael S. Branicky, Aug 18 2021
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.
Comments