A083920 Number of nontriangular numbers <= n.
0, 0, 1, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 15, 16, 17, 18, 19, 20, 21, 21, 22, 23, 24, 25, 26, 27, 28, 28, 29, 30, 31, 32, 33, 34, 35, 36, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 55, 56, 57, 58, 59, 60, 61, 62
Offset: 0
Keywords
Examples
a(7)=4 counts the nontriangular numbers, 2,4,5,7, that are <=7.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
- R. K. Guy, Sets of integers whose subsets have distinct sums, pp. 141-154 of Theory and practice of combinatorics. Ed. A. Rosa, G. Sabidussi and J. Turgeon. Annals of Discrete Mathematics, 12. North-Holland 1982. See Table 1, column (4).
Crossrefs
Programs
-
Haskell
a083920 n = a083920_list !! n a083920_list = scanl1 (+) $ map (1 -) a010054_list -- Reinhard Zumkeller, Feb 12 2012
-
Magma
[n-Floor((Sqrt(8*n+1)-1)/2):n in [1..75]]; // Marius A. Burtea, Jun 19 2019
-
Mathematica
f[n_] := n - Floor[(Sqrt[8n + 1] - 1)/2]; Table[ f[n], {n, 0, 73}] (* Robert G. Wilson v, Oct 22 2005 *) Accumulate[Table[If[OddQ[Sqrt[8n+1]],0,1],{n,0,120}]] (* Harvey P. Dale, Oct 14 2014 *)
-
PARI
a(n)=n-(sqrtint(8*n+1)-1)\2 \\ Charles R Greathouse IV, Sep 02 2015
-
Python
from math import isqrt def A083920(n): return n-(k:=isqrt(m:=n+1<<1))+((m>=k*(k+1)+1)^1) # Chai Wah Wu, Jun 07 2025
Formula
a(n) = n-floor((x-1)/2) = n-A003056(n), where x = sqrt(8*n+1).
A005318(n+1) = 2*A005318(n)-A205744(n), A205744(n) = A005318(a(n)), a(n) = n - A002024(n). - N. J. A. Sloane, Feb 11 2012
G.f.: 1/(1 - x)^2 - (1/(1 - x))*Product_{k>=1} (1 - x^(2*k))/(1 - x^(2*k-1)). - Ilya Gutkovskiy, May 30 2017
a(n) = n - floor(sqrt(2*n + 1) - 1/2). - Ridouane Oudra, Jun 19 2019
Extensions
Added alternative definition and Guy reference. - N. J. A. Sloane, Feb 09 2012
Comments