cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A083920 Number of nontriangular numbers <= n.

Original entry on oeis.org

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

Views

Author

Clark Kimberling, May 08 2003

Keywords

Comments

An alternative description: the sequence of nonnegative integers with the triangular numbers repeated.
a(t(n)) = t(n+1), where t(n)=A000217(n)=n(n+1)/2, the n-th triangular number. For n>=1, a(n)=a(n-1) if and only if n is a triangular number; otherwise, a(n)=1+a(n-1).

Examples

			a(7)=4 counts the nontriangular numbers, 2,4,5,7, that are <=7.
		

Crossrefs

Essentially partial sums of A023532.
Number of nonzero terms in row n+1 of A342557.

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