OFFSET
1,3
COMMENTS
Numbers n such that there are partitions into distinct parts from A001047. - Joerg Arndt, Apr 06 2014
Based on casting binary numbers as ternary numbers. - Jon Perry, Apr 12 2014
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..1000
FORMULA
A241759(a(n)) > 0. - Reinhard Zumkeller, Apr 28 2014
Recursive formula: For n >= 1, a(1)=1 then a(n) = n + 3*a(floor(n/2)). Sum: a(n) = Sum_{k=0..floor(log_2(n))} 3^k*floor(n/2^k). - Benoit Cloitre, Apr 06 2019
EXAMPLE
25 = 19 + 5 + 1 so 25 is in the sequence.
MATHEMATICA
max = 1000; nmax = FindRoot[3^n - 2^n == max, {n, 1}][[1, 2]] // Ceiling; partitions = Select[Table[{3^n - 2^n}, {n, 1, nmax}], (First[#] <= max)&] //. {a___, b_List, c___, d_List, e___} /; Total[b] + Total[d] <= max && FreeQ[p = {a, b, c, d, e}, (j = Join[b, d] // Sort)] && j == Union[j] :> Union[Append[p, j]]; Join[{0}, Total /@ partitions // Sort] (* Jean-François Alcover, Apr 16 2014 *)
PROG
(JavaScript)
function trimArray(arr) {
var c, i, j;
c = new Array();
for (j = 0; j < arr.length; j++) c[j] = arr[j];
c.sort(function(a, b) {return a - b; });
i = -1;
while(i++ < c.length - 1)
if (c[i] == c[i + 1]) c.splice(i--, 1);
return c;
}
a = new Array();
for (i = 0; i < 10; i++)
a[i] = Math.pow(3, i) - Math.pow(2, i);
b = new Array();
bc = 0;
for (j = 0; j < 130; j++) {
c = 0;
s = j.toString(2);
sl = s.length;
for (k = 0; k < sl; k++) if (s.charAt(k) == 1) c += a[k];
b[bc++] = c;
}
b = trimArray(b);
document.write(b);
(Haskell)
a240400 n = a240400_list !! (n-1)
a240400_list = filter ((> 0) . a241759) [0..]
-- Reinhard Zumkeller, Apr 28 2014
(PARI)
a(n)=if(n<2, n%2, n+3*a(floor(n/2)))
CROSSREFS
KEYWORD
nonn
AUTHOR
Jon Perry, Apr 04 2014
STATUS
approved