A034178 Number of solutions to n = a^2 - b^2, a > b >= 0.
1, 0, 1, 1, 1, 0, 1, 1, 2, 0, 1, 1, 1, 0, 2, 2, 1, 0, 1, 1, 2, 0, 1, 2, 2, 0, 2, 1, 1, 0, 1, 2, 2, 0, 2, 2, 1, 0, 2, 2, 1, 0, 1, 1, 3, 0, 1, 3, 2, 0, 2, 1, 1, 0, 2, 2, 2, 0, 1, 2, 1, 0, 3, 3, 2, 0, 1, 1, 2, 0, 1, 3, 1, 0, 3, 1, 2, 0, 1, 3, 3, 0, 1, 2, 2, 0, 2, 2, 1, 0, 2, 1, 2, 0, 2, 4, 1, 0, 3
Offset: 1
Examples
G.f. = x + x^3 + x^4 + x^5 + x^7 + x^8 + 2*x^9 + x^11 + x^12 + x^13 + 2*x^15 + ... From _Bernard Schott_, Apr 19 2019: (Start) a(8) = floor((A000005(2) + 1)/2) = floor(3/2) = 1 and 8 = 3^2 - 1^2. a(9) = floor((A000005(9) + 1)/2) = floor(4/2) = 2 and 9 = 3^2 - 0^2 = 5^2 - 4^2. a(10) = 0 and a^2 - b^2 = 10 has no solution. a(11) = floor(A000005(11) + 1)/2 = floor(3/2) = 1 and 11 = 6^2 - 5^2. (End)
Links
- T. D. Noe, Table of n, a(n) for n = 1..2000
- M. A. Nyblom, On the Representation of the Integers as a Difference of Squares, Fibonacci Quart., vol. 40 (2002), no. 3, 243-246.
- Edward T. H. Wang, Problem 1717, Crux Mathematicorum, page 30, Vol. 19, Jan. 93.
Programs
-
Mathematica
nn = 100; t = Table[0, {nn}]; Do[n = a^2 - b^2; If[n <= nn, t[[n]]++], {a, nn}, {b, 0, a - 1}];t (* T. D. Noe, May 04 2011 *) Table[Length[FindInstance[a^2-b^2==n&&a>b>=0,{a,b},Integers,10]],{n,100}] (* Harvey P. Dale, Jul 28 2021 *)
-
PARI
a(n)=sum(k=1, sqrtint(n), (n-k^2)%(2*k)==0) \\ Charles R Greathouse IV, Sep 27 2012
-
PARI
a(n)=sumdiv(n, d, n>=d^2 && (n-d^2)%(2*d)==0) \\ Charles R Greathouse IV, Sep 27 2012
-
Python
from sympy import divisor_count as d def a(n): return (d(n)+1)//2 if n%2==1 else ((d(n//4)+1)//2 if n%4==0 else 0) # Ely Golden, Jan 26 2025
Formula
From Naohiro Nomoto, Feb 26 2002: (Start)
a(2k+1) = A038548(2k+1). (End)
From Bernard Schott, Apr 11 2019: (Start) (see Crux link)
a(n) = 0 if n == 2 (mod 4)
a(n) = floor((A000005(n) + 1)/2) if n == 1 or n == 3 (mod 4)
a(n) = floor((A000005(n/4) + 1)/2) if n == 0 (mod 4). (End)
G.f.: Sum_{i>=1} Sum_{j>=i} Product_{k=i..j} x^(2*k-1). - Ilya Gutkovskiy, Apr 18 2019
G.f.: Sum_{n>=1} x^(n^2)/(1-x^(2*n)) (conjecture). - Joerg Arndt, Jan 04 2024
Comments