login
Number of ways to write n as a sum of a square and a nonsquare.
3

%I #8 Aug 10 2022 03:06:49

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

%T 4,6,5,5,7,7,5,5,7,7,7,5,7,7,7,6,5,8,6,6,8,8,8,8,6,8,8,6,8,8,7,5,9,9,

%U 7,9,9,9,8,7,7,9,9,9,9,9,7,8,8,10,10,6

%N Number of ways to write n as a sum of a square and a nonsquare.

%H Reinhard Zumkeller, <a href="/A247367/b247367.txt">Table of n, a(n) for n = 0..10000</a>

%e a(10) = #{0+10, 4+6} = 2;

%e a(11) = #{0+11, 1+10, 4+7, 9+2} = 4;

%e a(12) = #{0+12, 1+11, 4+8, 9+3} = 4;

%e a(13) = #{0+13, 1+12} = 2;

%e a(14) = #{0+14, 1+13, 4+10, 9+5} = 4;

%e a(15) = #{0+15, 1+14, 4+11, 9+6} = 4;

%e a(16) = #{1+15, 4+12, 9+7} = 3;

%e a(17) = #{0+17, 4+13, 9+8} = 3;

%e a(18) = #{0+18, 1+17, 4+14, 16+2} = 4;

%e a(19) = #{0+19, 1+18, 4+15, 9+10, 16+3} = 5;

%e a(20) = #{0+20, 1+19, 9+11} = 3.

%t sQ[n_] := sQ[n] = IntegerQ[Sqrt[n]];

%t a[n_] := Sum[Boole[sQ[k] && !sQ[n-k] || !sQ[k] && sQ[n-k]], {k, 0, Quotient[n, 2]}];

%t Table[a[n], {n, 0, 100}] (* _Jean-François Alcover_, Aug 10 2022 *)

%o (Haskell)

%o a247367 n = sum $ map ((1 -) . a010052 . (n -)) $

%o takeWhile (<= n) a000290_list

%Y Cf. A000037, A000290, A010052, A000925, A000161.

%K nonn

%O 0,4

%A _Reinhard Zumkeller_, Sep 14 2014