OFFSET
1,10
COMMENTS
Number of ways to regroup the unit squares of a rectangle with semiperimeter n into a square.
a(n) > 0 for n in A337140.
LINKS
David A. Corneth, Table of n, a(n) for n = 1..10000
FORMULA
Let n = 2^t * p_1^a_1 * p_2^a_2 * ... * p_r^a_r * q_1^b_1 * q_2^b_2 *...* q_s^b_s with t >= 0, a_i >= 0 for i = 1..r, where p_i == 1 (mod 4) and q_j == -1 (mod 4) for j = 1..s. Further, let A = (2a_1 + 1)*(2a_2 + 1)*...*(2a_r + 1). Then a(n) = (A-1)/2 for odd n and a(n) = A for even n.
EXAMPLE
n = 10 = 1 + 9 = 2 + 8 = 5 + 5 with 1*9 = 3^2 and 2*8 = 4^2 and 5*5 = 5^2. Then a(10) = 3. Also 10 = 2^1 * 5^1. So t=1, a_1=1 and a(n) = A = 2*1+1 = 3.
MAPLE
A338939:=n->map[fold=(`+`, 0)](i->if(issqr(i*(n-i)), 1, 0), [$1..1/2*n]); seq(A338939(n), n=1..100); # Felix Huber, Oct 02 2024
MATHEMATICA
a[n_] := Count[IntegerPartitions[n, {2}], _?(IntegerQ @ Sqrt[Times @@ #] &)]; Array[a, 100] (* Amiram Eldar, Nov 22 2020 *)
PROG
(PARI) a(n)=my(c=0); for(i=1, n-1, if((2*i<=n)&&issquare(i*(n-i)), c++)); c
for(n=1, 100, print1(a(n), ", ")) \\ Derek Orr, Nov 18 2020
(PARI) a(n) = sum(i=1, n-1, (2*i<=n) && issquare(i*(n-i))); \\ Michel Marcus, Dec 21 2020
(PARI) first(n) = {my(res = vector(n)); for(i = 1, n, d = divisors(i^2); for(i = (#d + 1)\2, #d, c = d[i] + d[#d + 1 - i]; if(c <= n, res[c]++ , next(2) ) ) ); res } \\ David A. Corneth, Dec 21 2020
(Python)
from sympy.abc import x, y
from sympy.solvers.diophantine.diophantine import diop_quadratic
def A338939(n): return len(diop_quadratic(x*(n-x)-y**2))>>2 # Chai Wah Wu, Aug 21 2024
CROSSREFS
KEYWORD
nonn,changed
AUTHOR
Hein van Winkel, Nov 16 2020
STATUS
approved