login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A339554 Number of subsets of {1..n} whose sum is a perfect power. 1

%I #20 Dec 11 2020 11:14:32

%S 1,1,2,5,9,15,25,48,99,187,326,543,896,1497,2568,4554,8504,17074,

%T 36011,75842,153964,298835,561337,1044317,1968266,3796589,7448571,

%U 14648620,28541211,54900185,104612044,198620706,377264405,717303565,1363083731,2585928327

%N Number of subsets of {1..n} whose sum is a perfect power.

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/PerfectPower.html">Perfect Power</a>

%e a(6) = 15 subsets: {1}, {4}, {1, 3}, {2, 6}, {3, 5}, {3, 6}, {4, 5}, {1, 2, 5}, {1, 2, 6}, {1, 3, 4}, {1, 3, 5}, {2, 3, 4}, {1, 4, 5, 6}, {2, 3, 5, 6} and {1, 2, 3, 4, 6}.

%o (Python)

%o from sympy import perfect_power

%o from functools import lru_cache

%o @lru_cache(maxsize=None)

%o def b(n, s, c):

%o if n == 0:

%o if c > 0 and (s==1 or perfect_power(s)): return 1

%o return 0

%o return b(n-1, s, c) + b(n-1, s+n, c+1)

%o a = lambda n: b(n, 0, 0)

%o print([a(n) for n in range(1, 37)]) # _Michael S. Branicky_, Dec 10 2020

%Y Cf. A001597, A126024, A126111, A339555.

%K nonn

%O 1,3

%A _Ilya Gutkovskiy_, Dec 08 2020

%E a(25)-a(36) from _Alois P. Heinz_, Dec 08 2020

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 13:58 EDT 2024. Contains 371960 sequences. (Running on oeis4.)