cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A240400 Numbers n having a partition into distinct parts of form 3^k-2^k.

Original entry on oeis.org

0, 1, 5, 6, 19, 20, 24, 25, 65, 66, 70, 71, 84, 85, 89, 90, 211, 212, 216, 217, 230, 231, 235, 236, 276, 277, 281, 282, 295, 296, 300, 301, 665, 666, 670, 671, 684, 685, 689, 690, 730, 731, 735, 736, 749, 750, 754, 755, 876, 877, 881, 882, 895, 896, 900, 901
Offset: 1

Views

Author

Jon Perry, Apr 04 2014

Keywords

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

Examples

			25 = 19 + 5 + 1 so 25 is in the sequence.
		

Crossrefs

Cf. A241783 (complement).

Programs

  • Haskell
    a240400 n = a240400_list !! (n-1)
    a240400_list = filter ((> 0) . a241759) [0..]
    -- Reinhard Zumkeller, Apr 28 2014
    
  • 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);
    
  • 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 *)
  • PARI
    a(n)=if(n<2,n%2,n+3*a(floor(n/2)))

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