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

A233074 Numbers that are exactly midway between the nearest square and the nearest triangular number.

Original entry on oeis.org

2, 5, 23, 32, 47, 52, 65, 86, 140, 161, 170, 193, 203, 228, 266, 312, 356, 389, 403, 438, 453, 490, 545, 610, 671, 716, 735, 782, 802, 851, 1007, 1085, 1142, 1166, 1250, 1311, 1503, 1598, 1667, 1696, 1767, 1870, 2098, 2177, 2210, 2291, 2325, 2408, 2528, 2792, 2883
Offset: 1

Views

Author

Alex Ratushnyak, Dec 03 2013

Keywords

Comments

Numbers k such that k = (s+t)/2, where s is the square nearest to k, t is the triangular number nearest to k, and s != t. If there are two nearest triangular numbers, either of them is acceptable. - Edited by Robert Israel, Oct 07 2019
The sequence of roots of nearest squares begins: 1, 2, 5, 6, 7, 7, 8, 9, 12, 13, 13, 14, 14, 15, 16, 18, 19, 20, 20, 21, 21, ...
The sequence of roots of nearest triangular numbers begins: 2, 3, 6, 7, 9, 10, 11, 13, 16, 17, 18, 19, 20, 21, 23, 24, 26, 27, 28, 29, ...
The sequence of k-t (equals s-k) begins: -1, -1, 2, 4, 2, -3, -1, -5, 4, 8, -1, 3, -7, -3, -10, 12, 5, 11, -3, 3, -12, -6, ...

Examples

			5 is in the sequence because 6 and 4 are the triangular number and square nearest to 5, and 5 = (6+4)/2.
23 is in the sequence because 21 and 25 are the triangular number and square nearest to 23, and 23 = (21+25)/2.
		

Crossrefs

Programs

  • Java
    import java.math.*;
    public class A233074 {
      public static void main (String[] args) {
        for (long n = 1; ; n++) { // ok for small n
          long r2 = (long)Math.sqrt(n), b2 = r2*r2, a2 = (r2+1)*(r2+1);
          long t = (long)Math.sqrt(2*n), b3 = t*(t+1)/2, a3 = b3 + t + 1;
          if (b3 > n) {
            a3 = b3;
            b3 = t*(t-1)/2;
          }
          if ((b2+a3 == n*2 && n - b2 <= a2 - n && a3 - n <= n - b3) ||
              (b3+a2 == n*2 && n - b3 <= a3 - n && a2 - n <= n - b2))
                System.out.printf("%d, ", n);
        }
      }
    }
  • Maple
    f:= proc(y) local t,x,s,r,R;
       t:= y*(y+1)/2;
       R:= NULL;
       for x from ceil(sqrt(t))-1 to floor(sqrt(t))+1 do
         s:= x^2;
         if s = t then next
         elif s < t then if t-y > s then next fi
         else if t+y+1 < s then next fi
         fi;
         r:= (s+t)/2;
         if r::integer then R:= R, r fi
       od;
       R
    end proc:
    map(f, [$1..200]; # Robert Israel, Oct 06 2019
  • Mathematica
    f[y_] := Module[{t, x, s, r, R = Nothing},
      t = y(y+1)/2;
      For[x = Ceiling[Sqrt[t]]-1, x <= Floor[Sqrt[t]]+1, x++,
        s = x^2;
        Which[s == t, Continue[], s < t,
        If[t - y > s, Continue[]], True,
        If[t + y + 1 < s, Continue[]]];
        r = (s + t)/2;
        If[IntegerQ[r], R = r]
      ];
    R];
    Map[f, Range[200]] (* Jean-François Alcover, Jul 30 2023, after Robert Israel *)

Extensions

Corrected by Alex Ratushnyak, Jun 08 2014

A233444 Primes that are exactly halfway between the nearest square and the nearest cube.

Original entry on oeis.org

2203, 90863, 185477, 388573, 613607, 912349, 1293899, 1600919, 2146457, 30661333, 35608189, 81190429, 105823093, 122753857, 204341747, 338602837, 368601707, 374788121, 426958673, 498675409, 586371239, 656232799, 665360321, 674509487, 693132527, 1102304669, 1180942709
Offset: 1

Views

Author

Alex Ratushnyak, Dec 09 2013

Keywords

Comments

A subsequence of A233075.

Crossrefs

Cf. A002760 (Squares and cubes).

Programs

  • Maple
    Res:= NULL:
    for x from 3 to 2000 do
      x3:= x^3;
      y:= floor(sqrt(x3));
      p:= (x3+y^2)/2;
      if p::integer and x3-p <= p - (x-1)^3 and p - y^2 <= (y+1)^2-p and isprime(p) then
        Res:= Res, p;
      fi;
      p:= (x3+(y+1)^2)/2;
      if p::integer and p-x3 <= (x+1)^3-p and (y+1)^2-p <= p - y^2 and isprime(p) then
          Res:= Res, p;
      fi
    od:
    Res; # Robert Israel, May 01 2018

A249875 Numbers that are exactly halfway between the nearest square and the nearest power of 2.

Original entry on oeis.org

3, 6, 34, 136, 498, 2082, 8146, 32946, 131058, 524232, 2096928, 8387712, 33550848, 134226562, 536859906, 2147439624, 8589943858, 34359775432, 137439101728, 549756406912, 2199022661826, 8796090647304, 35184374452498, 140737497809992, 562949943786834, 2251799775147336
Offset: 1

Views

Author

Alex Ratushnyak, Nov 07 2014

Keywords

Comments

Numbers that are the arithmetic mean of the nearest square and the nearest power of 2 (other than that nearest square).

Examples

			3 is a term because 2<3<4; 6 is a term because 4<6<8.
		

Crossrefs

Programs

  • Python
    def isqrt(a):
        sr = 1 << (a.bit_length() >> 1)
        while a < sr * sr:
            sr >>= 1
        b = sr >> 1
        while b:
            s = sr + b
            if a >= s * s:
                sr = s
            b >>= 1
        return sr
    for j in range(99):
        i = 2**j
        r = isqrt(i)
        if r * r == i:
            continue
        if r & 1:
            a = ((r + 1) * (r + 1) + i) // 2
        else:
            a = (i + r * r) // 2
        print(a, end=', ')
    
  • Python
    from gmpy2 import isqrt
    A249875_list, x = [], 1
    for _ in range(10**3):
        A249875_list.append(2*sum(divmod(isqrt(2*x),2))**2+x)
        x *= 4 # Chai Wah Wu, Dec 16 2014
Showing 1-3 of 3 results.