login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

a(n) = Sum_{b=0..floor(sqrt(n/2)), n-b^2 is square} b.
2

%I #16 Jan 31 2024 07:41:43

%S 0,1,0,0,1,0,0,2,0,1,0,0,2,0,0,0,1,3,0,2,0,0,0,0,3,1,0,0,2,0,0,4,0,3,

%T 0,0,1,0,0,2,4,0,0,0,3,0,0,0,0,6,0,4,2,0,0,0,0,3,0,0,5,0,0,0,5,0,0,2,

%U 0,0,0,6,3,5,0,0,0,0,0,4,0,1,0

%N a(n) = Sum_{b=0..floor(sqrt(n/2)), n-b^2 is square} b.

%C a(n) = 0 if n in A022544.

%C a(n) > 0 if n in A001481.

%H Project Euler, <a href="https://projecteuler.net/problem=273">Problem 273: Sum of Squares</a>

%p A363051 := proc(n)

%p local x,a ;

%p a := 0 ;

%p for x from 1 do

%p if x^2 > n/2 then

%p return a;

%p end if;

%p if issqr(n-x^2) then

%p a := a+x ;

%p end if;

%p end do:

%p end proc:

%p seq(A363051(n),n=1..100) ; # _R. J. Mathar_, Jan 31 2024

%t a[n_]:=Sum[b Boole[IntegerQ[Sqrt[n-b^2]]],{b,0,Floor[Sqrt[n/2]]}]; Array[a,83] (* _Stefano Spezia_, May 15 2023 *)

%o (Python)

%o from gmpy2 import *

%o a = lambda n: sum([b for b in range(0, isqrt(n >> 1) + 1) if is_square(n - (b*b))])

%o print([a(n) for n in range(1, 84)])

%o (Python)

%o from sympy.solvers.diophantine.diophantine import diop_DN

%o def A363051(n): return sum(min(a) for a in diop_DN(-1,n))>>1 # _Chai Wah Wu_, May 16 2023

%Y Cf. A022544, A001481, A362961.

%K nonn

%O 1,8

%A _DarĂ­o Clavijo_, May 14 2023