A231015 Least k such that n = +- 1^2 +- 2^2 +- 3^2 +- 4^2 +- ... +- k^2 for some choice of +- signs.
7, 1, 4, 2, 3, 2, 3, 6, 7, 6, 4, 6, 3, 5, 3, 5, 7, 6, 7, 6, 4, 5, 4, 5, 7, 9, 7, 5, 4, 5, 4, 6, 7, 6, 7, 5, 7, 5, 7, 6, 7, 6, 7, 9, 8, 5, 8, 5, 7, 6, 7, 6, 11, 5, 8, 5, 7, 6, 7, 6, 7, 10, 7, 6, 7, 6, 7, 9, 7, 10, 7, 6, 7, 6, 8, 9, 8, 9, 8, 9, 7, 6, 7, 6, 11, 9
Offset: 0
Examples
0 = 1^2 + 2^2 - 3^2 + 4^2 - 5^2 - 6^2 + 7^2. 1 = 1^2. 2 = - 1^2 - 2^2 - 3^2 + 4^2. 3 = - 1^2 + 2^2. 4 = - 1^2 - 2^2 + 3^2.
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..20000
- D. Andrica and E. J. Ionascu, Variations on a result of Erdős and Surányi, Integers Conference 2013 Abstract.
- D. Andrica and E. J. Ionascu, Variations on a result of Erdős and Surányi, INTEGERS 2013 slides.
- D. Andrica and D. Vacaretu, Representation theorems and almost unimodal sequences, Studia Univ. Babes-Bolyai, Mathematica, Vol. LI, 4 (2006), 23-33.
- P. Erdős and J. Surányi, Egy additív számelméleti probléma (in Hungarian; Russian and German summaries), Mat. Lapok 10 (1959), pp. 284-290.
Programs
-
Maple
b:= proc(n, i) option remember; local m; m:=i*(i+1)*(2*i+1)/6; n<=m and (n=m or b(n+i^2, i-1) or b(abs(n-i^2), i-1)) end: a:= proc(n) local k; for k while not b(n, k) do od; k end: seq(a(n), n=0..100); # Alois P. Heinz, Nov 03 2013
-
Mathematica
b[n_, i_] := b[n, i] = Module[{m}, m = i*(i+1)*(2*i+1)/6; n <= m && (n == m || b[n+i^2, i-1] || b[Abs[n-i^2], i-1])]; a[n_] := Module[{k}, For[k = 1, !b[n, k] , k++]; k]; Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Jan 28 2014, after Alois P. Heinz *)
Formula
Extensions
a(4) corrected and a(5)-a(85) from Donovan Johnson, Nov 03 2013
Comments