A196126 Let A = {(x,y): x, y positive natural numbers and y <= x <= y^2}. a(n) is the cardinality of the subset {(x,y) in A such that x <= n}.
1, 2, 4, 7, 10, 14, 19, 25, 32, 39, 47, 56, 66, 77, 89, 102, 115, 129, 144, 160, 177, 195, 214, 234, 255, 276, 298, 321, 345, 370, 396, 423, 451, 480, 510, 541, 572, 604, 637, 671
Offset: 1
Examples
The set is A = {(1,1),(2,2),(3,2),(4,2),(3,3),(4,3),(5,3),(6,3),(7,3),(8,3),(9,3),(4,4),(5,4),...}. a(1) = 1 that is the number of elements in {(1,1)}, a(2) = 2 that is the number of elements in {(1,1),(2,2)} and a(3) = 4 that is the number of elements in {(1,1),(2,2),(3,2),(3,3)}, ...
Programs
-
Mathematica
(* Calculates a(n) using the definition of the sequence. *) data = Flatten[Table[Table[{k, n}, {k, n, n^2}], {n, 1, 40}], 1]; Table[Length[Select[data, #[[1]] <= m &]], {m, 1, 40}] (* Calculates a(n) using a formula. *) ff[t_] := Block[{u}, u = Floor[Sqrt[t]]; u (u + 1) (2 u + 1)/6 - u (u - 1)/2 + (t - u) (t - u + 1)/2]; Table[ff[t], {t, 1, 40}]
-
PARI
a(n)=my(u=sqrtint(n));u*(u^2+2)/3+(n-u)*(n-u+1)/2 \\ Charles R Greathouse IV, Oct 05 2011
Formula
a(n) = u*(u+1)*(2*u+1)/6 - u*(u-1)/2 + (n-u)*(n-u+1)/2, where u = floor(sqrt(n)) = A000196(n).
Extensions
Entry rewritten by R. J. Mathar, Jan 28 2012
Comments