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.

Showing 1-5 of 5 results.

A022846 Nearest integer to n*sqrt(2).

Original entry on oeis.org

0, 1, 3, 4, 6, 7, 8, 10, 11, 13, 14, 16, 17, 18, 20, 21, 23, 24, 25, 27, 28, 30, 31, 33, 34, 35, 37, 38, 40, 41, 42, 44, 45, 47, 48, 49, 51, 52, 54, 55, 57, 58, 59, 61, 62, 64, 65, 66, 68, 69, 71, 72, 74, 75, 76, 78, 79, 81, 82, 83, 85, 86, 88, 89, 91, 92, 93, 95, 96
Offset: 0

Views

Author

Keywords

Comments

Let R(i,j) be the rectangle with antidiagonals 1; 2,3; 4,5,6; ...; n^2 is in antidiagonal number a(n). Proof: n^2 is in antidiagonal m iff A000217(m-1)< n^2 <=A000217(m), where A000217(m)=m*(m+1)/2. So m = A002024(n^2) = round(n*sqrt(2)) = a(n). - Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Mar 07 2003
In the rectangle R(i,j), n^2 is the number in row i=A057049(n) and column j=A057050(n), so that for n >= 1, a(n) = -1 + A057049(n) + A057050(n). - Clark Kimberling, Jan 31 2011
Number of triangular numbers less than n^2. - Philippe Deléham, Mar 08 2013

Examples

			n = 4, n^2 = 16; 0, 1, 3, 6, 10, 15 are triangular numbers in interval [0, 16); a(4) = 6. - _Philippe Deléham_, Mar 08 2013
		

Crossrefs

Cf. A063957 (complement of this set).
Cf. A214848 (first differences), also A006338.

Programs

  • Haskell
    a022846 = round . (* sqrt 2) . fromIntegral
    -- Reinhard Zumkeller, Mar 03 2014
    
  • Magma
    [Round(n*Sqrt(2)): n in [0..60]]; // Vincenzo Librandi, Oct 22 2011
    
  • Mathematica
    Round[Sqrt[2]Range[0,70]] (* Harvey P. Dale, Jun 18 2013 *)
  • PARI
    a(n)=round(n*sqrt(2))
    
  • Python
    from math import isqrt
    def A022846(n): return isqrt(n**2<<3)+1>>1 # Chai Wah Wu, Feb 10 2023

Formula

a(n) = A002024(n^2).
a(n+1) - a(n) = 1 or 2. - Philippe Deléham, Mar 08 2013

A006338 An "eta-sequence": floor((n+1)*sqrt(2) + 1/2) - floor(n*sqrt(2) + 1/2).

Original entry on oeis.org

2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2
Offset: 1

Views

Author

D. R. Hofstadter, Jul 15 1977

Keywords

Comments

Equals its own "second derivative" (cf. A006337).
Presumably this is the same as the following sequence from Hofstadter's book: the number of triangular numbers between each successive pair of squares. More precisely, a(n) is the number of triangular numbers T such that n^2 <= T < (n+1)^2. E.g., a(3) = 2 because 3^2 <= T < 4^2 permits T(4) = 10 and T(5) = 15 and no other triangular number. - Hugo van der Sanden, May 03 2005.
a(n) = A214848(n) = A022846(n+1) - A022846(n). - Reinhard Zumkeller, Mar 03 2014

References

  • Douglas Hofstadter, "Fluid Concepts and Creative Analogies", Chapter 1: "To seek whence cometh a sequence".
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • Haskell
    a006338 n = a006338_list !! (n-1)
    a006338_list = tail a214848_list
    -- Reinhard Zumkeller, Mar 03 2014
    
  • Magma
    [Floor((n+1)*Sqrt(2)+1/2) - Floor(n*Sqrt(2)+1/2): n in [1..30]]; // G. C. Greubel, Nov 18 2017
  • Mathematica
    a[n_] := Floor[(n+1)*Sqrt[2]+1/2] - Floor[n*Sqrt[2]+1/2]; Table[a[n], {n, 1, 105}] (* Jean-François Alcover, Nov 24 2015 *)
    Differences[Table[Floor[n Sqrt[2]+1/2],{n,120}]] (* Harvey P. Dale, Dec 10 2021 *)
  • PARI
    for(n=1,30, print1(floor((n+1)*sqrt(2) + 1/2) - floor(n*sqrt(2) + 1/2), ", ")) \\ G. C. Greubel, Nov 18 2017
    

Formula

a(n) = floor((n+1)*sqrt(2) + 1/2) - floor(n*sqrt(2) + 1/2). - G. C. Greubel, Nov 18 2017

Extensions

More terms from Antonio G. Astudillo (afg_astudillo(AT)lycos.com), Mar 28 2003

A214857 Number of triangular numbers in interval [0, n^2].

Original entry on oeis.org

1, 2, 3, 4, 6, 7, 9, 10, 11, 13, 14, 16, 17, 18, 20, 21, 23, 24, 25, 27, 28, 30, 31, 33, 34, 35, 37, 38, 40, 41, 42, 44, 45, 47, 48, 50, 51, 52, 54, 55, 57, 58, 59, 61, 62, 64, 65, 66, 68, 69, 71, 72, 74, 75, 76, 78, 79, 81, 82, 83, 85, 86, 88, 89, 91, 92, 93, 95, 96, 98, 99, 100
Offset: 0

Views

Author

Philippe Deléham, Mar 09 2013

Keywords

Comments

Partial sums of A214856.

Examples

			0, 1, 3, 6 are in interval [0, 9], a(3) = 4.
0, 1, 3, 6, 10, 15 are in interval [0, 16], a(4) = 6.
		

Crossrefs

Programs

Formula

a(n) = floor((1 + sqrt(1+8*n^2))/2). - Ralf Stephan, Jan 30 2014

A214856 Number of triangular numbers in interval ](n-1)^2, n^2] for n>0, a(0)=1.

Original entry on oeis.org

1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1
Offset: 0

Views

Author

Philippe Deléham, Mar 08 2013

Keywords

Examples

			10, 15 are in interval ]9, 16] , a(4) = 2.
		

Crossrefs

Programs

  • PARI
    a(n) = if (n, sum(i=(n-1)^2+1, n^2, ispolygonal(i, 3)), 1); \\ Michel Marcus, Nov 12 2022
    
  • Python
    from math import isqrt
    def A214856(n): return (isqrt((m:=n**2<<3)+8)+1>>1)-(isqrt(m-(n-1<<4))+1>>1) if n else 1 # Chai Wah Wu, Dec 09 2024

A236346 Manhattan distances between n^2 and (n+1)^2 in a left-aligned triangle with next M natural numbers in row M: 1, 2 3, 4 5 6, 7 8 9 10, etc.

Original entry on oeis.org

2, 3, 4, 4, 5, 6, 6, 8, 7, 10, 8, 9, 12, 10, 14, 11, 12, 16, 13, 18, 14, 20, 15, 16, 22, 17, 24, 18, 19, 26, 20, 28, 21, 22, 30, 23, 32, 24, 34, 25, 26, 36, 27, 38, 28, 29, 40, 30, 42, 31, 44, 32, 33, 46, 34, 48, 35, 36, 50, 37, 52, 38, 54, 39, 40, 56, 41, 58
Offset: 1

Views

Author

Alex Ratushnyak, Jan 23 2014

Keywords

Comments

Triangle in which we find distances begins:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35 36
37 38 39 40 41 42 43 44 45
Subsequence of terms such that a(m)>=a(m-1) and a(m)>=a(m+1) seems to be A005843 (even numbers) except first two terms, and if such a(m) are removed, the remainder seems to be A000027 (natural numbers) except 1:
2, 3, *4*, 4, 5, *6*, 6, *8*, 7, *10*, 8, 9, *12*, 10, *14*, 11, 12, *16*, 13, *18*, 14, *20*, 15, ...

Crossrefs

Programs

  • Python
    import math
    def getXY(n):
      y = int(math.sqrt(n*2))
      if n<=y*(y+1)//2: y-=1
      x = n - y*(y+1)//2
      return x, y
    for n in range(1, 77):
      ox, oy = getXY(n*n)
      nx, ny = getXY((n+1)**2)
      print(abs(nx-ox)+abs(ny-oy), end=', ')

Formula

a(n) = A214848(n) + |A057049(n+1) - A057049(n)|. - David Radcliffe, Aug 06 2025
Showing 1-5 of 5 results.