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-8 of 8 results.

A101160 a(n) is the smallest integer j for which n+(n+1)+...+(n+j) is a square.

Original entry on oeis.org

0, 2, 4, 0, 8, 10, 12, 14, 0, 18, 2, 1, 24, 26, 28, 0, 32, 4, 36, 38, 7, 42, 44, 1, 0, 2, 52, 54, 56, 58, 60, 8, 64, 66, 5, 0, 7, 74, 10, 1, 80, 82, 4, 86, 8, 12, 2, 94, 0, 98, 100, 17, 14, 106, 108, 110, 7, 9, 116, 1, 120, 23, 124, 0, 128
Offset: 1

Views

Author

Charlie Marion, Dec 29 2004

Keywords

Comments

Basis for sequence is shortest arithmetic sequence with initial term n and difference 1 that sums to a perfect square. Cf. A100251, A100252, A100253, A100254.
0 <= a(n) <= 2*(n - 1). - Ctibor O. Zizka, Oct 05 2023

Examples

			a(11)=2 since j=2 is the smallest integer for which 11+...+11+j = 6^2 = 36 is a perfect square.
		

Crossrefs

Programs

  • PARI
    a(n) = {j = 0; while(! issquare(sum(k=0, j, n+k)), j++); j;} \\ Michel Marcus, Sep 01 2013

Formula

n+(n+1)+...+(n+a(n)) = n+(n+1)+...+A101159(n) = A101157(n)^2 = A101158(n).
a(n^2) = 0. - Michel Marcus, Jun 28 2013

Extensions

More terms from Michel Marcus, Jun 28 2013

A232176 Least positive k such that n^2 + triangular(k) is a square.

Original entry on oeis.org

1, 2, 6, 10, 14, 18, 7, 5, 8, 34, 6, 42, 46, 15, 54, 16, 14, 66, 70, 74, 23, 82, 9, 90, 17, 98, 102, 10, 110, 15, 25, 122, 126, 16, 39, 48, 40, 21, 150, 34, 158, 29, 54, 48, 30, 13, 182, 63, 55, 194, 56, 202, 14, 45, 214, 63, 222, 26, 41, 234, 31, 42, 39, 250, 32, 63
Offset: 0

Views

Author

Alex Ratushnyak, Nov 19 2013

Keywords

Comments

Triangular(k) = A000217(k) = k*(k+1)/2.
a(n) <= 4*n - 2, because with k = 4*n-2: n^2 + k*(k+1)/2 = n^2 + (4*n-2)*(4*n-1)/2 = 9*n^2 - 6*n + 1 = (3*n-1)^2.
The sequence of numbers n such that a(n)=n begins: 8, 800, 7683200 ... - a subsequence of A220186.

Crossrefs

Cf. A232179 (least k>=0 such that n^2 + triangular(k) is a triangular number).
Cf. A101157 (least k>0 such that triangular(n) + k^2 is a triangular number).
Cf. A232178 (least k>=0 such that triangular(n) + k^2 is a square).

Programs

  • Mathematica
    lpk[n_]:=Module[{k=1},While[!IntegerQ[Sqrt[n^2+(k(k+1))/2]],k++];k]; Array[ lpk,70,0] (* Harvey P. Dale, May 04 2018 *)
  • PARI
    a(n) = {k = 1; while (! issquare(n^2 + k*(k+1)/2), k++); k;} \\ Michel Marcus, Nov 20 2013
  • Python
    import math
    for n in range(77):
      n2 = n*n
      y=1
      for k in range(1,10000001):
        sum = n2 + k*(k+1)//2
        r = int(math.sqrt(sum))
        if r*r == sum:
          print(str(k), end=',')
          y=0
          break
      if y: print('-', end=',')
    

A101158 Let j be the smallest integer for which n+(n+1)+...+(n+j) is a square; sequence gives the squares.

Original entry on oeis.org

1, 9, 25, 4, 81, 121, 169, 225, 9, 361, 36, 25, 625, 729, 841, 16, 1089, 100, 1369, 1521, 196, 1849, 2025, 49, 25, 81, 2809, 3025, 3249, 3481, 3721, 324, 4225, 4489, 225, 36, 324, 5625, 484, 81, 6561, 6889, 225, 7569, 441, 676, 144, 9025, 49, 9801
Offset: 1

Views

Author

Charlie Marion, Dec 29 2004

Keywords

Comments

Basis for sequence is shortest arithmetic sequence with initial term n and difference 1 that sums to a perfect square. Cf. A100251, A100252, A100253, A100254.

Examples

			a(11)=36 since 11+12+13 = 36.
		

Crossrefs

Formula

n+(n+1)+...+(n+A101160(n)) = n+(n+1)+...+A101159(n) = A101157(n)^2 = a(n).
a(n^2) = n^2. - Michel Marcus, Jun 28 2013

Extensions

a(21) corrected by Michel Marcus, Jun 29 2013

A101159 Let j be the smallest integer for which n+(n+1)+...+(n+j) is a square; then a(n) = n+j.

Original entry on oeis.org

1, 4, 7, 4, 13, 16, 19, 22, 9, 28, 13, 13, 37, 40, 43, 16, 49, 22, 55, 58, 28, 64, 67, 25, 25, 28, 79, 82, 85, 88, 91, 40, 97, 100, 40, 36, 44, 112, 49, 41, 121, 124, 47, 130, 53, 58, 49, 142, 49, 148, 151, 69, 67, 160, 163, 166, 64, 67, 175, 61
Offset: 1

Views

Author

Charlie Marion, Dec 29 2004

Keywords

Comments

Basis for sequence is shortest arithmetic sequence with initial term n and difference 1 that sums to a perfect square. Cf. A100251, A100252, A100253, A100254.

Examples

			a(11)=13 since j=13 is the smallest integer such that 11+...+j=6^2=36 is a perfect square.
		

Crossrefs

Programs

  • PARI
    a(n) = {my(j = 0); while(! issquare(sum(k=0, j, n+k)), j++); n+j;} \\ Michel Marcus, May 02 2018
    
  • PARI
    a(n) = my(s = n, t = 0); while(!issquare(s), s += n + t++); n + t \\ David A. Corneth, May 05 2018

Formula

n+(n+1)+...+(n+A101160(n)) = n+(n+1)+...+a(n) = A101157(n)^2 = A101158(n).
a(n^2) = n^2. - Michel Marcus, Jun 28 2013
a(n) <= 3*n - 2. - David A. Corneth, May 03 2018

Extensions

More terms from Michel Marcus, Jun 28 2013

A232178 Least k>=0 such that triangular(n) + k^2 is a square, or -1 if no such k exists.

Original entry on oeis.org

0, 0, 1, -1, -1, 1, 2, 6, 0, 2, 3, -1, -1, 3, 4, 1, 15, 4, 5, -1, -1, 5, 6, 20, 10, 6, 7, -1, -1, 7, 8, 27, 1, 8, 9, -1, -1, 9, 10, 2, 36, 10, 11, -1, -1, 11, 12, 41, 7, 0, 13, -1, -1, 13, 6, 24, 2, 14, 15, -1, -1, 15, 16, 3, 6, 8, 17, -1, -1, 17, 18, 62, 64, 18, 19
Offset: 0

Views

Author

Alex Ratushnyak, Nov 20 2013

Keywords

Comments

Triangular(n) = n*(n+1)/2.

Examples

			a(7) = 6 because the least k such that triangular(n) + k^2 is a square is k=6: 7*(7+1)/2 + 6^2 = 28+36 = 64 = 8^2.
		

Crossrefs

Cf. A082183 (least k>0 such that triangular(n) + triangular(k) is a triangular number).
Cf. A232177 (least k>0 such that triangular(n) + triangular(k) is a square).
Cf. A232176 (least k>0 such that n^2 + triangular(k) is a square).
Cf. A232179 (least k>=0 such that n^2 + triangular(k) is a triangular number).
Cf. A101157 (least k>0 such that triangular(n) + k^2 is a triangular number).

Programs

  • Mathematica
    Join[{0}, Table[k = 0; While[k < n && ! IntegerQ[Sqrt[n*(n + 1)/2 + k^2]], k++]; If[k == n, k = -1]; k, {n, 100}]] (* T. D. Noe, Nov 21 2013 *)
  • Python
    from _future_ import division
    from sympy import divisors
    def A232178(n):
        if n == 0:
            return 0
        t = n*(n+1)//2
        ds = divisors(t)
        l, m = divmod(len(ds),2)
        if m:
            return 0
        for i in range(l-1,-1,-1):
            x = ds[i]
            y = t//x
            a, b = divmod(y-x,2)
            if not b:
                return a
        return -1 # Chai Wah Wu, Sep 12 2017

A232179 Least k >= 0 such that n^2 + triangular(k) is a triangular number.

Original entry on oeis.org

0, 0, 3, 1, 15, 2, 0, 3, 63, 4, 8, 5, 11, 6, 20, 3, 255, 8, 1, 9, 3, 10, 38, 11, 59, 12, 45, 13, 8, 14, 2, 15, 1023, 16, 59, 0, 24, 18, 66, 19, 51, 20, 3, 21, 44, 10, 80, 23, 251, 24, 42, 25, 68, 26, 4, 27, 39, 28, 101, 29, 10, 30, 108, 8, 4095, 32, 5, 33, 128
Offset: 0

Views

Author

Alex Ratushnyak, Nov 20 2013

Keywords

Comments

Triangular(k) = k*(k+1)/2.

Crossrefs

Cf. A082183 (least k>0 such that triangular(n) + triangular(k) is a triangular number).
Cf. A232177 (least k>0 such that triangular(n) + triangular(k) is a square).
Cf. A232176 (least k>0 such that n^2 + triangular(k) is a square).
Cf. A101157 (least k>0 such that triangular(n) + k^2 is a triangular number).
Cf. A232178 (least k>=0 such that triangular(n) + k^2 is a square).

Programs

  • Mathematica
    TriangularQ[n_] := IntegerQ[Sqrt[1 + 8*n]]; Table[k = 0; While[! TriangularQ[n^2 + k*(k + 1)/2], k++]; k, {n, 0, 68}] (* T. D. Noe, Nov 21 2013 *)
  • PARI
    a(n) = {my(k = 0); while (! ispolygonal(n^2 + k*(k+1)/2, 3), k++); k;} \\ Michel Marcus, Sep 15 2017
  • Python
    from _future_ import division
    from sympy import divisors
    def A232179(n):
        if n == 0:
            return 0
        t = 2*n**2
        ds = divisors(t)
        for i in range(len(ds)//2-1,-1,-1):
            x = ds[i]
            y = t//x
            a, b = divmod(y-x,2)
            if b:
                return a
        return -1 # Chai Wah Wu, Sep 12 2017
    

Formula

a(A001109(n)) = 0.

A232177 Least positive k such that triangular(n) + triangular(k) is a square.

Original entry on oeis.org

1, 2, 1, 2, 3, 1, 5, 6, 7, 8, 9, 5, 2, 12, 13, 1, 15, 16, 17, 3, 5, 20, 2, 22, 23, 8, 4, 26, 12, 3, 29, 30, 1, 5, 33, 34, 4, 36, 37, 15, 6, 29, 22, 5, 43, 19, 45, 7, 15, 48, 6, 50, 11, 52, 8, 41, 22, 7, 57, 58, 59, 9, 26, 62, 8, 64, 19, 66, 10, 68, 5, 9, 71, 2
Offset: 0

Views

Author

Alex Ratushnyak, Nov 20 2013

Keywords

Comments

Triangular(k) = A000217(k) = k*(k+1)/2.
For n>1, a(n) <= n-1, because with k=n-1: triangular(n) + triangular(k) = n*(n+1)/2 + (n-1)*n/2 = n^2.

Crossrefs

Cf. A082183 (least k>0 such that triangular(n) + triangular(k) is a triangular number).
Cf. A212614 (least k>1 such that triangular(n) * triangular(k) is a triangular number).
Cf. A232176 (least k>0 such that n^2 + triangular(k) is a square).
Cf. A232179 (least k>=0 such that n^2 + triangular(k) is a triangular number).
Cf. A101157 (least k>0 such that triangular(n) + k^2 is a triangular number).
Cf. A232178 (least k>=0 such that triangular(n) + k^2 is a square).

Programs

  • Mathematica
    Table[k = 1; tri = n*(n + 1)/2; While[k <= n+2 && ! IntegerQ[Sqrt[tri + k*(k + 1)/2]], k++]; k, {n, 0, 100}] (* T. D. Noe, Nov 21 2013 *)
  • Python
    import math
    for n in range(77):
      tn = n*(n+1)//2
      for k in range(1, n+9):
        sum = tn + k*(k+1)//2
        r = int(math.sqrt(sum))
        if r*r == sum:
          print(str(k), end=',')
          break

A225844 Least k>0 such that triangular(n) + k*(k+1) is a triangular number.

Original entry on oeis.org

2, 1, 3, 5, 7, 2, 11, 13, 5, 17, 19, 3, 6, 25, 27, 9, 31, 33, 35, 4, 9, 41, 8, 45, 47, 10, 14, 53, 9, 5, 59, 61, 21, 18, 67, 69, 21, 73, 75, 14, 22, 6, 11, 13, 87, 15, 91, 26, 20, 34, 12, 101, 26, 105, 30, 7, 20, 33, 115, 117, 119, 34, 21, 125, 37, 129, 29, 133, 14, 137
Offset: 0

Views

Author

Alex Ratushnyak, May 17 2013

Keywords

Comments

For n>0, a(n) <= 2*n-1, because n*(n+1)/2 + (2*n-1)*2*n = (9*n^2 - 3*n)/2 = 3*n*(3*n-1)/2 = triangular(3*n-1).
The subsequence with terms less than 2*n-1 begins: 2, 5, 3, 6, 9, 4, 9, 8, 10, 14, 9, 5, 21, 18, 21, 14, 22, 6, 11, 13, 15, ...
The sequence of n's such that a(n) < 2*n-1 begins: 5, 8, 11, 12, 15, 19, 20, 22, 25, 26, ...

Crossrefs

Cf. A101157 (least k>0 such that triangular(n) + k^2 is a triangular number).

Programs

  • Maple
    a:= proc(n) option remember; local w, k; w:= n*(n+1)/2;
          for k while not issqr(8*(w+k*(k+1))+1) do od; k
        end:
    seq(a(n), n=0..69);  # Alois P. Heinz, Nov 13 2024
  • Mathematica
    lktrno[n_]:=Module[{t=(n(n+1))/2,k=1},While[!IntegerQ[(Sqrt[ 8(t+k(k+1))+1]-1)/2],k++];k]; Array[lktrno,70,0] (* Harvey P. Dale, Aug 19 2014 *)
  • PARI
    a(n)=for(k=1,2*n,t=n*(n+1)/2+k*(k+1);x=sqrtint(2*t);if(t==x*(x+1)/2,return(k))) /* from Ralf Stephan */
  • Python
    def isTriangular(a):
        sr = 1 << (a.bit_length() >> 1)
        a += a
        while a < sr*(sr+1):  sr>>=1
        b = sr>>1
        while b:
          s = sr+b
          if a >= s*(s+1):  sr = s
          b>>=1
        return (a==sr*(sr+1))
    n = tn = 0
    while 1:
      for m in range(1, 1000000000):
        if isTriangular(tn + m*(m+1)): break
      print(m, end=', ')
      n += 1
      tn += n
    
Showing 1-8 of 8 results.