login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A350403 Number of solutions to +-1^2 +- 2^2 +- 3^2 +- ... +- n^2 = 0 or 1. 2
1, 1, 0, 0, 0, 0, 2, 2, 2, 5, 2, 2, 10, 13, 43, 86, 114, 193, 274, 478, 860, 1552, 3245, 5808, 10838, 18628, 31048, 55626, 100426, 188536, 372710, 696164, 1298600, 2376996, 4197425, 7826992, 14574366, 27465147, 53072709, 100061106, 187392994, 351329160 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,7
LINKS
EXAMPLE
a(8) = 2: +1^2 - 2^2 - 3^2 + 4^2 - 5^2 + 6^2 + 7^2 - 8^2 =
-1^2 + 2^2 + 3^2 - 4^2 + 5^2 - 6^2 - 7^2 + 8^2 = 0.
MAPLE
b:= proc(n, i) option remember; `if`(n>i*(i+1)*(2*i+1)/6, 0,
`if`(i=0, 1, b(n+i^2, i-1)+b(abs(n-i^2), i-1)))
end:
a:=n-> b(0, n)+b(1, n):
seq(a(n), n=0..42); # Alois P. Heinz, Jan 16 2022
MATHEMATICA
b[n_, i_] := b[n, i] = If[n > i*(i + 1)*(2*i + 1)/6, 0,
If[i == 0, 1, b[n + i^2, i - 1] + b[Abs[n - i^2], i - 1]]];
a[n_] := b[0, n] + b[1, n];
Table[a[n], {n, 0, 42}] (* Jean-François Alcover, Mar 01 2022, after Alois P. Heinz *)
PROG
(Python)
from itertools import product
def a(n):
if n == 0: return 1
nn = ["0"] + [str(i)+"**2" for i in range(1, n+1)]
return sum(eval("".join([*sum(zip(nn, ops+("", )), ())])) in {0, 1} for ops in product("+-", repeat=n))
print([a(n) for n in range(18)]) # Michael S. Branicky, Jan 16 2022
(Python)
from functools import cache
@cache
def b(n, i):
if n > i*(i+1)*(2*i+1)//6: return 0
if i == 0: return 1
return b(n+i**2, i-1) + b(abs(n-i**2), i-1)
def a(n): return b(0, n) + b(1, n)
print([a(n) for n in range(43)]) # Michael S. Branicky, Jan 16 2022 after Alois P. Heinz
CROSSREFS
Sequence in context: A342550 A115281 A130155 * A113516 A226525 A120642
KEYWORD
nonn
AUTHOR
Ilya Gutkovskiy, Dec 29 2021
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 28 04:07 EDT 2024. Contains 372020 sequences. (Running on oeis4.)