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.

Showing 1-6 of 6 results.

A055401 Number of positive cubes needed to sum to n using the greedy algorithm.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 8, 2, 3, 4, 5, 6, 7, 8, 9, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 2, 3, 4, 5, 6, 7, 8, 9, 3, 4, 5, 6, 7, 8, 9, 10, 4, 5, 6, 2, 3, 4, 5, 6, 7, 8, 9, 3, 4, 1, 2, 3, 4, 5, 6, 7, 8, 2, 3, 4, 5, 6, 7, 8, 9, 3, 4, 5, 6, 7, 8, 9, 10, 4, 5, 6, 2, 3, 4, 5, 6, 7, 8, 9, 3, 4, 5, 6, 7
Offset: 0

Views

Author

Henry Bottomley, May 16 2000

Keywords

Comments

Define f(n) = n - k^3 where (k+1)^3 > n >= k^3; a(n) = number of steps such that f(f(...f(n)))= 0.
Also sum of digits when writing n in base where place values are positive cubes, cf. A000433. [Reinhard Zumkeller, May 08 2011]

Examples

			a(32)=6 because 32=27+1+1+1+1+1 (not 32=8+8+8+8).
a(33)=7 because 33=27+1+1+1+1+1+1 (not 33=8+8+8+8+1).
		

Crossrefs

Cf. A002376 (least number of positive cubes needed to represent n; differs from this sequence for the first time at n=32, where a(32)=6, while A002376(32)=4).

Programs

  • Haskell
    a055401 n = s n $ reverse $ takeWhile (<= n) $ tail a000578_list where
      s _ []                 = 0
      s m (x:xs) | x > m     = s m xs
                 | otherwise = m' + s r xs where (m',r) = divMod m x
    -- Reinhard Zumkeller, May 08 2011
    (Scheme, with memoization-macro definec)
    (definec (A055401 n) (if (zero? n) n (+ 1 (A055401 (A055400 n)))))
    ;; Antti Karttunen, Aug 16 2015
  • Maple
    f:= proc(n,k) local m, j;
    if n = 0 then return 0 fi;
    for j from k by -1 while j^3 > n do od:
    m:= floor(n/j^3);
    m + procname(n-m*j^3, j-1);
    end proc:
    seq(f(n,floor(n^(1/3))),n=0..100); # Robert Israel, Aug 17 2015
  • Mathematica
    a[0] = 0; a[n_] := {n} //. {b___, c_ /; !IntegerQ[c^(1/3)], d___} :> {b, f = Floor[c^(1/3)]^3, c - f, d} // Length; Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Aug 17 2015 *)
  • PARI
    F=vector(30,n,n^3); /* modify to get other sequences of "greedy representations" */ last_leq(v,F)=
    { /* Return last element <=v in sorted array F[] */
        local(j=1);
        while ( F[j]<=v, j+=1 );
        return( F[j-1] );
    }
    greedy(n,F)=
    {
        local(v=n,ct=0);
        while ( v,  v-=last_leq(v,F); ct+=1; );
        return(ct);
    }
    vector(min(100,F[#F-1]),n,greedy(n,F)) /* show terms */
    /* Joerg Arndt, Apr 08 2011 */
    

Formula

a(0) = 0; for n >= 1, a(n) = a(n-floor(n^(1/3))^3)+1 = a(A055400(n))+1 = a(n-A048762(n))+1.

Extensions

a(0) = 0 prepended by Antti Karttunen, Aug 16 2015

A261225 n minus the number of positive cubes needed to sum to n using the greedy algorithm: a(n) = n - A055401(n).

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 14, 14, 14, 14, 14, 14, 14, 14, 21, 21, 21, 26, 26, 26, 26, 26, 26, 26, 26, 33, 33, 33, 33, 33, 33, 33, 33, 40, 40, 40, 40, 40, 40, 40, 40, 47, 47, 47, 52, 52, 52, 52, 52, 52, 52, 52, 59, 59, 63, 63, 63, 63, 63, 63, 63, 63, 70, 70, 70, 70, 70, 70, 70, 70, 77, 77, 77, 77, 77, 77, 77, 77, 84, 84, 84, 89
Offset: 0

Views

Author

Antti Karttunen, Aug 16 2015

Keywords

Examples

			a(8) = 7, because when the greedy algorithm partitions 8 into cubes, it first finds 8 (= 2*2*2), thus A055401(8) = 1, and 8-1 = 7.
		

Crossrefs

Formula

a(n) = n - A055401(n).
As a recurrence:
a(0) = 0; for n >= 1, a(n) = -1 + A048762(n) + a(n-A048762(n)). [Where A048762(n) gives the largest cube <= n.]

A261228 a(n) = number of steps to reach 0 when starting from k = (n^3)-1 and repeatedly applying the map that replaces k with k - A055401(k), where A055401(k) = the number of positive cubes needed to sum to k using the greedy algorithm.

Original entry on oeis.org

0, 1, 4, 10, 19, 33, 52, 77, 108, 146, 190, 244, 306, 377, 458, 549, 652, 767, 896, 1038, 1195, 1367, 1554, 1757, 1978, 2216, 2472, 2746, 3040, 3353, 3688, 4045, 4423, 4823, 5247, 5696, 6169, 6668, 7193, 7745, 8324, 8933, 9570, 10236, 10934, 11663, 12423, 13215, 14042, 14902, 15797, 16726, 17693, 18695, 19734, 20811, 21928, 23083, 24278, 25513
Offset: 1

Views

Author

Antti Karttunen, Aug 16 2015

Keywords

Crossrefs

One less than A261227.
First differences: A261229.
Cf. also A261223.

Formula

a(1) = 0; for n > 1, a(n) = A261229(n-1) + a(n-1).
a(n) = A261226((n^3)-1).

A261229 a(n) = number of steps to reach (n^3)-1 when starting from k = ((n+1)^3)-1 and repeatedly applying the map that replaces k with k - A055401(k), where A055401(k) = the number of positive cubes needed to sum to k using the greedy algorithm.

Original entry on oeis.org

1, 3, 6, 9, 14, 19, 25, 31, 38, 44, 54, 62, 71, 81, 91, 103, 115, 129, 142, 157, 172, 187, 203, 221, 238, 256, 274, 294, 313, 335, 357, 378, 400, 424, 449, 473, 499, 525, 552, 579, 609, 637, 666, 698, 729, 760, 792, 827, 860, 895, 929, 967, 1002, 1039, 1077, 1117, 1155, 1195, 1235, 1278, 1318, 1361, 1404, 1448, 1492, 1538, 1583, 1631, 1677, 1725
Offset: 1

Views

Author

Antti Karttunen, Aug 16 2015

Keywords

Crossrefs

First differences of both A261227 and A261228.
Cf. also A261224.

Formula

a(n) = A261226(((n+1)^3)-1) - A261226((n^3)-1). [The definition.]
Equally, for all n >= 1:
a(n) = A261226((n+1)^3) - A261226(n^3).
a(n) = A261227(n+1) - A261227(n).
a(n) = A261228(n+1) - A261228(n).

A261227 a(n) = number of steps to reach 0 when starting from k = n^3 and repeatedly applying the map that replaces k with k - A055401(k), where A055401(k) = the number of positive cubes needed to sum to k using the greedy algorithm.

Original entry on oeis.org

0, 1, 2, 5, 11, 20, 34, 53, 78, 109, 147, 191, 245, 307, 378, 459, 550, 653, 768, 897, 1039, 1196, 1368, 1555, 1758, 1979, 2217, 2473, 2747, 3041, 3354, 3689, 4046, 4424, 4824, 5248, 5697, 6170, 6669, 7194, 7746, 8325, 8934, 9571, 10237, 10935, 11664, 12424, 13216, 14043, 14903, 15798, 16727, 17694, 18696, 19735, 20812, 21929, 23084, 24279, 25514
Offset: 0

Views

Author

Antti Karttunen, Aug 16 2015

Keywords

Crossrefs

Essentially one more than A261228.
First differences: A261229.
Cf. also A261222.

Formula

a(0) = 0, a(1) = 1; for n >= 2, a(n) = A261229(n-1) + a(n-1).
a(n) = A261226(n^3).

A261221 a(n) = number of steps to reach 0 when starting from k = n and repeatedly applying the map that replaces k with k - A053610(k), where A053610(k) = the number of positive squares needed to sum to k using the greedy algorithm.

Original entry on oeis.org

0, 1, 1, 1, 2, 2, 2, 2, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 21, 22, 22, 22, 23, 24, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29
Offset: 0

Views

Author

Antti Karttunen, Aug 12 2015

Keywords

Crossrefs

Formula

a(0) = 0; for n >= 1, a(n) = 1 + a(A260740(n)).
Showing 1-6 of 6 results.