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.

Previous Showing 11-19 of 19 results.

A236564 Difference between 2^(2n-1) and the nearest square.

Original entry on oeis.org

1, -1, -4, 7, -17, 23, -89, 7, 28, 112, 448, 1792, -4417, 5503, 22012, -4633, -18532, -74128, -296512, 296863, 1187452, -1181833, -4727332, 4817239, 19268956, -17830441, -71321764, 94338007, 377352028, -9092137, -36368548, -145474192, -581896768, -2327587072, -9310348288
Offset: 1

Views

Author

Alex Ratushnyak, Feb 23 2014

Keywords

Comments

The distances of the even powers 2^(2n) to their nearest squares are obviously all zero and therefore skipped.

Examples

			a(1) = 2^1 - 1^2 = 1.
a(2) = 2^3 - 3^2 = -1.
a(3) = 2^5 - 6^2 = 32 - 36 = -4.
		

Crossrefs

Programs

  • Maple
    A236564 := proc(n)
        local x,sq,lo,hi ;
        x := 2^(2*n-1) ;
        sq := isqrt(x) ;
        lo := sq^2 ;
        hi := (sq+1)^2 ;
        if abs(x-lo) < abs(x-hi) then
            x-lo ;
        else
            x-hi ;
        end if;
    end proc: # R. J. Mathar, Mar 13 2014
  • Mathematica
    Table[2^n - Round[Sqrt[2^n]]^2, {n, 1, 79, 2}] (* Alonso del Arte, Feb 23 2014 *)
  • Python
    def isqrt(a):
        sr = 1 << (int.bit_length(int(a)) >> 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 n in range(47):
        nn = 2**(2*n+1)
        a = isqrt(nn)
        d1 = nn - a*a
        d2 = (a+1)**2 - nn
        if d2 < d1:  d1 = -d2
        print(str(d1), end=',')

Formula

If A201125(n) < A238454(n), a(n) = A201125(n), otherwise a(n) = -A238454(n). [Negative terms are for cases where the nearest square is above 2^(2n-1), not below it.] - Antti Karttunen, Feb 27 2014

A359736 Lexicographically earliest sequence of distinct nonnegative integers such that the sequence d(n) = dist(a(n), SQUARES) has the same sequence of digits.

Original entry on oeis.org

0, 10, 1, 2, 6, 42, 20, 7, 11, 4, 56, 3, 5, 21, 30, 43, 12, 31, 14, 8, 13, 9, 29, 19, 15, 18, 22, 17, 24, 32, 72, 26, 28, 90, 23, 91, 35, 109, 37, 41, 48, 73, 27, 34, 50, 57, 38, 40, 33, 47, 71, 51, 62, 55, 66, 89, 112, 16, 79, 39, 130, 63, 46, 44, 65, 25, 135
Offset: 0

Views

Author

M. F. Hasler and Eric Angelini, Jan 12 2023

Keywords

Comments

In the definition, dist(a(n), SQUARES) = A053188(a(n)) is the distance of a(n) from the nearest square. "... has the same digits" means that the concatenation of the terms yields the same string of digits, for the sequence a(.) and the sequence d(.).
Conjectured to be a permutation of the nonnegative integers. The inverse permutation would start (0, 2, 3, 11, 9, 12, 4, 7, 19, 21, 1, 8, 16, 20, 18, 24, ...)

Examples

			Below, row "s" lists the closest square to a(n) and row "d" the absolute difference |a(n)-s|. We have the same sequence of digits in rows a (this sequence) and d:
  n :  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14 ...
  a :  0  10   1   2   6  42  20   7  11   4  56   3   5  21  30 ...
  s :  0   9   1   1   4  36  16   9   9   4  49   4   6  25  25 ...
  d :  0   1   0   1   2   6   4   2   2   0   7   1   1   4   5 ...
		

Crossrefs

Cf. A053188 (distance from the nearest square), A000290 (the squares).
Cf. A359734, A359737 (similar for primes and Fibonacci numbers).

Programs

  • PARI
    spine(x->x^2, 200) \\ See A359734 for spine()

A080344 Partial sums of A023969.

Original entry on oeis.org

0, 0, 0, 1, 1, 1, 1, 2, 3, 3, 3, 3, 3, 4, 5, 6, 6, 6, 6, 6, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 16, 17, 18, 19, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 23, 24, 25, 26, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 30, 31, 32, 33, 34, 35
Offset: 0

Views

Author

N. J. A. Sloane, Mar 20 2003

Keywords

Crossrefs

Programs

  • Magma
    [1/2*(n+1-Floor(Sqrt(n+1)+1/2)-Abs(n+1-(Floor(Sqrt(n+1)+1/2))^2)):n in [0..90]]; // Marius A. Burtea, May 09 2019
    
  • PARI
    f(n) = sqrtint(4*n)-2*sqrtint(n); \\ A023969
    a(n) = sum(k=0, n, f(k)); \\ Michel Marcus, May 10 2019
    
  • Python
    from math import isqrt
    def A080344(n): return n+1-(k:=(m:=isqrt(n+1))+int(n>=m*(m+1)))-abs(n+1-k**2)>>1 # Chai Wah Wu, Jun 05 2025

Formula

From Ridouane Oudra, May 11 2019: (Start)
a(n) = (1/2)*(n + 1 - t - abs(n + 1 - t^2)), where t = floor(sqrt(n+1) + 1/2).
a(n) = (1/2)*(n + 1 - A000194(n+1) - abs(n + 1 - A000194(n+1)^2)).
a(n) = (1/2)*(A056847(n+1) - A053188(n+1)). (End)

A301636 Square array T(n, k) read by antidiagonals upwards, n >= 0 and k >= 0: T(n, k) = square of the distance from n + k*i to nearest square of a Gaussian integer (where i denotes the root of -1 with positive imaginary part).

Original entry on oeis.org

0, 0, 1, 1, 1, 0, 1, 2, 1, 1, 0, 2, 4, 2, 4, 1, 1, 4, 2, 4, 9, 4, 2, 4, 1, 1, 5, 4, 4, 5, 5, 2, 0, 2, 5, 1, 1, 5, 8, 5, 1, 1, 5, 2, 0, 0, 2, 8, 10, 4, 2, 4, 5, 1, 1, 1, 1, 5, 10, 8, 5, 5, 9, 4, 2, 4, 4, 2, 4, 9, 5, 5, 8, 10, 9, 5, 5, 9, 9, 5, 5, 9, 4, 2, 4, 10
Offset: 0

Views

Author

Rémy Sigrist, Mar 25 2018

Keywords

Comments

The distance between two Gaussian integers is not necessarily integer, hence the use of the square of the distance.
This sequence is a complex variant of A053188.
See A301626 for the square array dealing with cubes of Gaussian integers.

Examples

			Square array begins:
  n\k|    0    1    2    3    4    5    6    7    8    9   10
  ---+-------------------------------------------------------
    0|    0    1    0    1    4    9    4    1    0    1    4
    1|    0    1    1    2    4    5    5    2    1    2    5
    2|    1    2    4    2    1    2    5    5    4    5    8
    3|    1    2    4    1    0    1    4    9    9   10    8
    4|    0    1    4    2    1    2    5   10   16   10    5
    5|    1    2    5    5    4    5    8   10   13    9    4
    6|    4    5    8   10    8    5    4    5    8   10    5
    7|    4    5    8   10    5    2    1    2    5   10    8
    8|    1    2    5    9    4    1    0    1    4    9   13
    9|    0    1    4    9    5    2    1    2    5   10   17
   10|    1    2    5   10    8    5    4    5    8   13   20
		

Crossrefs

Programs

  • PARI
    See Links section.

Formula

T(n, 0) <= A053188(n)^2.
T(n, 0) = 0 iff n is a square (A000290).
T(0, k) = 0 iff k is twice a square (A001105).
T(n, k) = 0 iff n + k*i = z^2 for some Gaussian integer z.

A131866 Distance of n-th semiprime to nearest square.

Original entry on oeis.org

0, 2, 0, 1, 2, 1, 4, 3, 0, 1, 3, 2, 1, 2, 3, 3, 0, 2, 6, 7, 6, 2, 1, 5, 7, 4, 1, 4, 5, 6, 9, 7, 6, 5, 6, 10, 6, 3, 2, 0, 1, 2, 8, 11, 10, 3, 2, 1, 1, 2, 11, 11, 10, 8, 3, 0, 8, 9, 13, 11, 9, 2, 5, 6, 7, 9, 10, 13, 12, 11, 10, 8, 7, 6, 4, 1, 10, 12, 9, 7, 3, 2, 3, 6, 9, 11, 15, 11, 2, 0, 2, 6, 9, 10, 12
Offset: 1

Views

Author

Jonathan Vos Post, Oct 04 2007

Keywords

Comments

This to semiprimes A001358 as A047972 is to primes A000040.
For each semiprime, find the closest square (preceding or succeeding); subtract, take absolute value.

Examples

			a(1) = 0 because the first semiprime is 4, which is a square.
a(2) = 2 because the 2nd semiprime is 6 and |6-4| = 2 where 4 is the nearest square to 6.
a(3) = 0 because the 3rd semiprime is 9, which is a square.
a(4) = 1 because the 4th semiprime is 10 and |10-9| = 1 where 9 is the nearest square to 10.
		

Crossrefs

Programs

  • Mathematica
    dns[n_]:=Min[n-Floor[Sqrt[n]]^2,Ceiling[Sqrt[n]]^2-n]; dns/@Select[ Range[ 400],PrimeOmega[#]==2&] (* Harvey P. Dale, Aug 12 2016 *)

Formula

a(n)=A053188(A001358(n)) (corrected by R. J. Mathar, Nov 19 2007).

Extensions

More terms from R. J. Mathar, Oct 24 2007

A133610 Partial sums of pyramidal sequence A053616.

Original entry on oeis.org

0, 0, 1, 1, 2, 3, 3, 4, 6, 7, 7, 8, 10, 12, 13, 13, 14, 16, 19, 21, 22, 22, 23, 25, 28, 31, 33, 34, 34, 35, 37, 40, 44, 47, 49, 50, 50, 51, 53, 56, 60, 64, 67, 69, 70, 70, 71, 73, 76, 80, 85, 89, 92, 94, 95, 95, 96, 98, 101, 105, 110, 115, 119, 122, 124, 125, 125, 126, 128, 131, 135
Offset: 0

Views

Author

Jonathan Vos Post, Dec 28 2007

Keywords

Crossrefs

Programs

  • Haskell
    a133610 n = a133610_list !! n
    a133610_list = scanl1 (+) a053616_list
    -- Reinhard Zumkeller, Jan 24 2014

Formula

a(n) = SUM[i=0..n] distance from i to nearest triangular number = SUM[i=0..n]MIN{|i - (k*(k+1)/2)|} = SUM[i=0..n] MIN{|A000217(i) - i|}.

Extensions

Data corrected by Reinhard Zumkeller, Jan 24 2014

A289642 Number of 2-digit numbers whose digits add up to n.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1
Offset: 1

Views

Author

Miquel Cerda, Jul 09 2017

Keywords

Comments

The 2-digit numbers distributed according to the sum of their digits n.
Symmetrical sequence; a(n) = a(19 - n).

Examples

			n(5) = 5 because there are 5 numbers whose digits sum = 5 (14, 23, 32, 41, 50).
		

Crossrefs

Cf. A071817 (3-digit numbers), A090579 (4-digit numbers), A090580 (5-digit numbers), A090581 (6-digit numbers), A278969 (7-digit numbers), A278971 (8-digit numbers), A289354 (9-digit numbers), A053188, A074989, A004739, A066635, A154840, A249121.

Formula

G.f.: (1 - x^10)*(x - x^10)/(1 - x)^2.
a(n) = (19-abs(n-9)-abs(n-10))/2 for n=1..18. - Wesley Ivan Hurt, Jul 09 2017

A301297 Distance from n to nearest Catalan number.

Original entry on oeis.org

0, 0, 1, 1, 0, 1, 2, 3, 4, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 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
Offset: 1

Views

Author

N. J. A. Sloane, Mar 24 2018

Keywords

Crossrefs

A309914 Distance from n to closest triangular number that is different from n.

Original entry on oeis.org

1, 1, 1, 2, 1, 1, 3, 1, 2, 1, 4, 1, 2, 2, 1, 5, 1, 2, 3, 2, 1, 6, 1, 2, 3, 3, 2, 1, 7, 1, 2, 3, 4, 3, 2, 1, 8, 1, 2, 3, 4, 4, 3, 2, 1, 9, 1, 2, 3, 4, 5, 4, 3, 2, 1, 10, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 11, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 12, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 13, 1, 2, 3, 4, 5, 6, 7, 6, 5
Offset: 0

Views

Author

Ilya Gutkovskiy, Aug 22 2019

Keywords

Crossrefs

Programs

  • Mathematica
    a[n_] := Module[{k = 1}, While[! IntegerQ[Sqrt[8 (n + k) + 1]] && ! IntegerQ[Sqrt[8 (n - k) + 1]], k++]; k]; Table[a[n], {n, 0, 100}]
Previous Showing 11-19 of 19 results.