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.

A138554 Minimal value of sum k_i when sum (k_i)^2 = n.

Original entry on oeis.org

0, 1, 2, 3, 2, 3, 4, 5, 4, 3, 4, 5, 6, 5, 6, 7, 4, 5, 6, 7, 6, 7, 8, 9, 8, 5, 6, 7, 8, 7, 8, 9, 8, 9, 8, 9, 6, 7, 8, 9, 8, 9, 10, 11, 10, 9, 10, 11, 12, 7, 8, 9, 10, 9, 10, 11, 12, 11, 10, 11, 12, 11, 12, 13, 8, 9, 10, 11, 10, 11, 12, 13, 12, 11, 12, 13, 14, 13, 14, 15, 12, 9, 10, 11, 12, 11
Offset: 0

Views

Author

Keywords

Examples

			32 = 4^2 + 4^2 and 4+4 = 8. Using 5, the best we can do is 32 = 5^2 + 2^2 + 1^2 + 1^2 + 1^2 and 5+2+1+1+1 = 10, so a(32) = 8.
		

Crossrefs

Programs

  • Maple
    b:= proc(n, i) option remember; `if`(n=0 or i=1, n,
           min(seq(b(n-j*i^2, i-1)+j*i, j=0..n/i^2)))
        end:
    a:= n-> b(n, isqrt(n)):
    seq(a(n), n=0..100);  # Alois P. Heinz, Jun 30 2015
  • Mathematica
    b[n_, i_] := b[n, i] = If[n == 0 || i == 1, n, Min[Table[b[n - j i^2, i - 1] + j i, {j, 0, n/i^2}]]];
    a[n_] := b[n, Sqrt[n] // Floor];
    a /@ Range[0, 100] (* Jean-François Alcover, Nov 05 2020, after Alois P. Heinz *)
  • PARI
    sslist(n) = {local(r,i,v,t); r=vector(n+1,k,0); for(k=1,n,v=k;i=1;while(i^2<=k,t=r[k-i^2+1]+i;if(t