%I #48 Jan 04 2024 09:11:01
%S 1,1,1,2,1,1,2,1,2,2,1,1,2,2,1,3,1,1,3,1,1,2,2,2,3,1,1,2,2,2,2,1,1,4,
%T 1,2,3,1,2,2,1,1,3,3,1,2,2,1,4,1,2,3,1,2,2,1,1,4,2,1,3,2,1,4,2,1,2,1,
%U 3,3,1,2,2,2,2,2,1,1,6,2,2,2,1,2,2,2,1,4,2,1,3,1,2,4,1,1,3,2,2,4,2,2,2,2,1
%N Number of ways of subtracting twice a triangular number from a perfect square to obtain the integer n.
%C Also number of symmetric unimodal consecutive integer sequences that sum to the integer n (e.g., 4+5+6+5+4 = 24 = n). Also number of double trapezoidal arrangements of n objects, denoted SDT(n); i.e., the number of ways to arrange n objects into symmetrically-placed, congruent isosceles trapezoids adjoined at overlapping largest bases.
%C Also number of divisors of 4*n-1 of form 4*k+1 (or 4*k+3). - _Vladeta Jovovic_, Jan 05 2004. Therefore a(n) is one half of the number of divisors of A004767(n-1) (numbers 3 (mod 4)). - _Wolfdieter Lang_, Jul 29 2016
%H Seiichi Manyama, <a href="/A078703/b078703.txt">Table of n, a(n) for n = 1..10000</a>
%H T. Verhoeff, <a href="http://www.cs.uwaterloo.ca/journals/JIS/trapzoid.html">Rectangular and Trapezoidal Arrangements</a>, J. Integer Sequences, Vol. 2 (1999), Article 99.1.6.
%F a(n) = ((r1 + 1)*(r2 + 1)*...*(rk + 1))/2, where ((p1^r1)*(p2^r2)*...*(pk^rk)) is the factorization of 4*n - 1 into (odd) primes.
%F G.f.: Sum_{n>0} x^n/(1-x^(4*n-1)). - _Vladeta Jovovic_, Jan 05 2004
%F a(n) = A034178(4*n - 1). - _Michael Somos_, May 11 2011
%F G.f.: Sum_{n >= 1} x^(3*n-2)/(1 - x^(4*n-3)). - _Peter Bala_, Jan 08 2021
%F From _Amiram Eldar_, Dec 26 2022: (Start)
%F a(n) = A000005(A004767(n-1))/2.
%F Sum_{k=1..n} a(k) = (log(n) + 2*gamma - 1 + 4*log(2))*n/4 + O(n^(1/3)*log(n)), where gamma is Euler's constant (A001620). (End)
%F G.f.: Sum_{n >= 1} x^(n^2)/(1-x^(2*n-1)) (conjecture). - _Joerg Arndt_, Jan 04 2024
%e SDT(34) = 4 since we have 34 or 11+12+11 or 6+7+8+7+6 or 2+3+4+5+6+5+4+3+2, Also 4*34 - 1 = 135 = (3^3)*(5^1) so that r1=3 and r2=1 (p1=3 and p2=5), resulting in SDT(34) = (3+1)*(1+1)/2 = 4.
%e a(4) = 2 since 4 = 2^2 - 2*0 = 4^2 - 2*6. Also A034178(4*4 - 1) = 2 since 15 = 4^2 - 1^2 = 8^2 - 7^2. - _Michael Somos_, May 11 2011
%e G.f. = x + x^2 + x^3 + 2*x^4 + x^5 + x^6 + 2*x^7 + x^8 + 2*x^9 + 2*x^10 + x^11 + ...
%e Number of divisors of numbers 3 (mod 4) (see the Jovovic Jan 05 2004 comment): a(16) = 3 from the 2*3 = 6 divisors [1, 3, 7, 9, 21, 63] of 63 = A004767(15), being 1, -1, -1, 1, 1, -1 (mod 4). - _Wolfdieter Lang_, Jul 29 2016
%t (* This defines SDT(n): *)
%t SDT[n_] := Length[Cases[Range[1, n], j_ /; Cases[Range[1, j], k_ /; Plus @@ Join[Range[k, j], Range[j - 1, k, -1]] == n] != {}]] The restricted factorization technique for obtaining SDT(n) is encoded as follows: SDT[n_] := (Times @@ Cases[FactorInteger[4 n - 1], {p_, r_} -> r + 1])/2
%t Rest[ CoefficientList[ Series[ Sum[x^k/(1 - x^(4k - 1)), {k, 111}], {x, 0, 110}], x]] (* _Robert G. Wilson v_, Sep 20 2005 *)
%t a[ n_] := If[ n < 1, 0, With[{m = 4 n - 1}, Sum[1 - Sign@Mod[m - k^2, 2 k], {k, Sqrt@m}]]]; (* _Michael Somos_, Aug 01 2016 *)
%t a[n_] := DivisorSigma[0, 4*n - 1]/2; Array[a, 100] (* _Amiram Eldar_, Dec 26 2022 *)
%o (PARI) {a(n) = if( n<1, 0, n = 4*n-1; sum(k=1, sqrtint(n), 0 == (n - k^2) % (2*k)))}; /* _Michael Somos_, Aug 01 2016 */
%Y Cf. A000005, A001620, A004767, A001227, A034178, A359227, A359240.
%K nonn,easy
%O 1,4
%A R. L. Coffman, K. W. McLaughlin and R. J. Dawson (robert.l.coffman(AT)uwrf.edu), Dec 19 2002