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

A081249 Partial sums of A081134.

Original entry on oeis.org

0, 1, 1, 2, 4, 7, 9, 10, 10, 11, 13, 16, 20, 25, 31, 38, 46, 55, 63, 70, 76, 81, 85, 88, 90, 91, 91, 92, 94, 97, 101, 106, 112, 119, 127, 136, 146, 157, 169, 182, 196, 211, 227, 244, 262, 281, 301, 322, 344, 367, 391, 416, 442, 469, 495, 520, 544, 567, 589, 610, 630
Offset: 1

Views

Author

Klaus Brockhaus, Mar 17 2003

Keywords

Examples

			First seven terms of A081134 are 0,1,0,1,2,3,2, so a(7) = 9.
		

Programs

  • Mathematica
    Accumulate[Flatten[Table[Join[Range[0,3^n],Range[3^n-1,1,-1]],{n,0,4}]]] (* Harvey P. Dale, Sep 21 2016 *)
  • PARI
    {s=0; for(n=1,62,p=3^floor(0.1^25+log(n)/log(3)); print1(s=s+min(n-p,3*p-n),","))}

Formula

a(n) = sum{j=1..n, A081134(j)}.

A053646 Distance to nearest power of 2.

Original entry on oeis.org

0, 0, 1, 0, 1, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 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, 15, 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
Offset: 1

Views

Author

Henry Bottomley, Mar 22 2000

Keywords

Comments

Sum_{j=1..2^(k+1)} a(j) = A002450(k) = (4^k - 1)/3. - Klaus Brockhaus, Mar 17 2003

Examples

			a(10)=2 since 8 is closest power of 2 to 10 and |8-10| = 2.
		

Crossrefs

Programs

  • Maple
    a:= n-> (h-> min(n-h, 2*h-n))(2^ilog2(n)):
    seq(a(n), n=1..100);  # Alois P. Heinz, Mar 28 2021
  • Mathematica
    np2[n_]:=Module[{min=Floor[Log[2,n]],max},max=min+1;If[2^max-nHarvey P. Dale, Feb 21 2012 *)
  • PARI
    a(n)=vecmin(vector(n,i,abs(n-2^(i-1))))
    
  • PARI
    for(n=1,89,p=2^floor(0.1^25+log(n)/log(2)); print1(min(n-p,2*p-n),","))
    
  • PARI
    a(n) = my (p=#binary(n)); return (min(n-2^(p-1), 2^p-n)) \\ Rémy Sigrist, Mar 24 2018
    
  • Python
    def A053646(n): return min(n-(m := 2**(len(bin(n))-3)),2*m-n) # Chai Wah Wu, Mar 08 2022

Formula

a(2^k+i) = i for 1 <= i <= 2^(k-1); a(3*2^k+i) = 2^k-i for 1 <= i <= 2^k; (Sum_{k=1..n} a(k))/n^2 is bounded. - Benoit Cloitre, Aug 17 2002
a(n) = min(n-2^floor(log(n)/log(2)), 2*2^floor(log(n)/log(2))-n). - Klaus Brockhaus, Mar 08 2003
From Peter Bala, Aug 04 2022: (Start)
a(n) = a( 1 + floor((n-1)/2) ) + a( ceiling((n-1)/2) ).
a(2*n) = 2*a(n); a(2*n+1) = a(n) + a(n+1) for n >= 2. Cf. A006165. (End)
a(n) = 2*A006165(n) - n for n >= 2. - Peter Bala, Sep 25 2022

A081250 Numbers k such that A081249(m)/m^2 has a local minimum for m = k.

Original entry on oeis.org

1, 3, 11, 33, 101, 303, 911, 2733, 8201, 24603, 73811, 221433, 664301, 1992903, 5978711, 17936133, 53808401, 161425203, 484275611, 1452826833, 4358480501, 13075441503, 39226324511, 117678973533, 353036920601, 1059110761803
Offset: 0

Views

Author

Klaus Brockhaus, Mar 17 2003

Keywords

Comments

The limit of the local minima, lim_{n->infinity} A081249(n)/n^2 = 1/10. For local maxima cf. A081251.

Examples

			11 is a term since A081249(10)/10^2 = 11/100 = 0.110, A081249(11)/11^2 = 13/121 = 0.107, A081249(12)/12^2 = 16/144 = 0.111.
		

Crossrefs

Programs

  • GAP
    List([0..30], n-> (5*3^n +(-1)^n -2)/4); # G. C. Greubel, Jul 14 2019
  • Magma
    [Floor(3^n*5/4): n in [0..30]]; // Vincenzo Librandi, Jun 10 2011
    
  • Maple
    a[0]:=1:a[1]:=3:for n from 2 to 50 do a[n]:=2*a[n-1]+3*a[n-2]+2 od: seq(a[n], n=0..30); # Zerinvary Lajos, Apr 28 2008
  • Mathematica
    Floor[5*3^Range[0, 30]/4] (* Wesley Ivan Hurt, Mar 30 2017 *)
  • PARI
    vector(30, n, n--; (5*3^n +(-1)^n -2)/4) \\ G. C. Greubel, Jul 14 2019
    
  • Sage
    [(5*3^n +(-1)^n -2)/4 for n in (0..30)] # G. C. Greubel, Jul 14 2019
    

Formula

a(n) = floor(3^n*5/4).
G.f.: x*(1+x^2)/((1-x)*(1+x)*(1-3*x)).
a(n) = 3*a(n-1) + 1*a(n-2) - 3*a(n-3).
a(n) = (5*3^n + (-1)^n - 2)/4. - Paul Barry, May 19 2003
a(n) = a(n-2) + 10*3^(n-2) for n > 1.
a(n+2) - a(n) = A005052(n).
a(2*n) = Sum_{j=1..n+1} A062107(2*j).
a(2*n+1) = Sum_{j=1..n+1} A062107(2*j+1).
With a leading 0, this is a(n) = (5*3^n - 6 + 4*0^n - 3*(-1)^n)/12, the binomial transform of A084183. - Paul Barry, May 19 2003
Convolution of 3^n and {1, 0, 2, 0, 2, 0, ...}. a(n) = Sum_{k=0..n} ((1 + (-1)^k) - 0^k)*3^(n-k) = Sum_{k=0..n} ((1 + (-1)^(n-k)) - 0^(n-k))3^k. - Paul Barry, Jul 19 2004
a(n) = 2*a(n-1) + 3*a(n-2) + 2, a(0)=1, a(1)=3. - Zerinvary Lajos, Apr 28 2008

Extensions

Offset changed from 1 to 0 by Vincenzo Librandi, Jun 10 2011

A081251 Numbers n such that A081249(m)/m^2 has a local maximum for m = n.

Original entry on oeis.org

2, 6, 20, 60, 182, 546, 1640, 4920, 14762, 44286, 132860, 398580, 1195742, 3587226, 10761680, 32285040, 96855122, 290565366, 871696100, 2615088300, 7845264902, 23535794706, 70607384120, 211822152360, 635466457082, 1906399371246
Offset: 1

Views

Author

Klaus Brockhaus, Mar 17 2003

Keywords

Comments

The limit of the local maxima, lim A081249(n)/n^2 = 1/6. For local minima cf. A081250.
Also the number of different 4- and 3-colorings for the vertices of all triangulated planar polygons on a base with n+2 vertices, if the colors of the two base vertices are fixed. - Patrick Labarque, Mar 23 2010
From Toby Gottfried, Apr 18 2010: (Start)
a(n) = the number of ternary sequences of length n+1 where the numbers of (0's, 1's) are both odd.
A015518 covers the (odd, even) and (even, odd) cases, and A122983 covers (even, even). (End)

Examples

			6 is a term since A081249(5)/5^2 = 4/25 = 0.160, A081249(6)/6^2 = 7/36 = 0.194, A081249(7)/7^2 = 9/49 = 0.184.
		

Crossrefs

Programs

  • GAP
    List([1..30], n-> (9*3^(n-1) -(-1)^n -2)/4); # G. C. Greubel, Jul 14 2019
  • Magma
    [Floor(3^(n+1)/4) : n in [1..30]]; // Vincenzo Librandi, Jun 25 2011
    
  • Maple
    seq(floor(3^(n+1)/4), n=1..30). # Mircea Merca, Dec 27 2010
  • Mathematica
    a[n_]:= Floor[3^(n+1)/4]; Array[a, 30]
    Table[(9*3^(n-1) -(-1)^n -2)/4, {n, 1, 30}] (* G. C. Greubel, Jul 14 2019 *)
  • PARI
    vector(30, n, (9*3^(n-1) -(-1)^n -2)/4) \\ G. C. Greubel, Jul 14 2019
    
  • Sage
    [(9*3^(n-1) -(-1)^n -2)/4 for n in (1..30)] # G. C. Greubel, Jul 14 2019
    

Formula

G.f.: 2/((1-x)*(1+x)*(1-3*x)).
a(n) = a(n-2) + 2*3^(n) for n > 1.
a(n+2) - a(n) = A008776(n).
a(n) = 2*A033113(n+1).
a(2*n+1) = A054880(n+1).
a(n) = floor(3^(n+1)/4). - Mircea Merca, Dec 26 2010
From G. C. Greubel, Jul 14 2019: (Start)
a(n) = (9*3^(n-1) -(-1)^n -2)/4.
E.g.f.: (3*exp(3*x) - 2*exp(x) - exp(-x))/4. (End)

A296239 a(n) = distance from n to nearest Fibonacci number.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Dec 09 2017

Keywords

Comments

The Fibonacci numbers correspond to sequence A000045.
This sequence is analogous to:
- A051699 (distance to nearest prime),
- A053188 (distance to nearest square),
- A053646 (distance to nearest power of 2),
- A053615 (distance to nearest oblong number),
- A053616 (distance to nearest triangular number),
- A061670 (distance to nearest power),
- A074989 (distance to nearest cube),
- A081134 (distance to nearest power of 3),
The local maxima of the sequence correspond to positive terms of A004695.
a(n) = 0 iff n = A000045(k) for some k >= 0.
a(n) = 1 iff n = A061489(k) for some k > 4.
For any n >= 0, abs(a(n+1) - a(n)) <= 1.
For any n > 0, a(n) < n, and a^k(n) = 0 for some k > 0 (where a^k denotes the k-th iterate of a); k equals A105446(n) for n = 1..80 (and possibly more values).
a(n) > max(a(n-1), a(n+1)) iff n = A001076(k) for some k > 1.

Examples

			For n = 42:
- A000045(9) = 34 <= 42 <= 55 = A000045(10),
- a(42) = min(42 - 34, 55 - 42) = min(8, 13) = 8.
		

Crossrefs

Programs

  • Mathematica
    fibPi[n_] := 1 + Floor[ Log[ GoldenRatio, 1 + n*Sqrt@5]]; f[n_] := Block[{m = fibPi@ n}, Min[n - Fibonacci[m -1], Fibonacci[m] - n]]; Array[f, 81, 0] (* Robert G. Wilson v, Dec 11 2017 *)
    With[{nn=80,fibs=Fibonacci[Range[0,20]]},Table[Abs[n-Nearest[fibs,n]][[1]],{n,0,nn}]] (* Harvey P. Dale, Jul 02 2022 *)
  • PARI
    a(n) = for (i=1, oo, if (n<=fibonacci(i), return (min(n-fibonacci(i-1), fibonacci(i)-n))))

Formula

a(n) = abs(n - Fibonacci(floor(log(sqrt(20)*n)/log((1 + sqrt(5))/2)-1))). - Jon E. Schoenfield, Dec 14 2017

A006166 a(0)=0, a(1)=a(2)=1; for n >= 1, a(3n+2) = 2a(n+1) + a(n), a(3n+1) = a(n+1) + 2a(n), a(3n) = 3a(n).

Original entry on oeis.org

0, 1, 1, 3, 3, 3, 3, 5, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69
Offset: 0

Views

Author

Keywords

References

  • J. Arkin, D. C. Arney, L. S. Dewald and W. E. Ebel, Jr., Families of recursive sequences, J. Rec. Math., 22 (No. 22, 1990), 85-94.
  • vN. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

a(n) + n = A003605(n). Cf. A006165, A080678, A081134.

Formula

From Peter Bala, Oct 08 2022: (Start)
a(n+2) - a(n) = 0 or 2.
a(3^k + j) = 3^k for k >= 0 and for 0 <= j <= 3^k.
a(2*3^k + j) = 3^k + 2*j for k >= 0 and for 0 <= j <= 3^k.
A081134(n) = n - a(n). (End)

Extensions

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

A342872 Distance to nearest product of 3 consecutive numbers (three-dimensional promic number, A007531).

Original entry on oeis.org

0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 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, 17, 16, 15, 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
Offset: 0

Views

Author

Lamine Ngom, Mar 28 2021

Keywords

Examples

			a(13) = 7 since 6 is the closest three-dimensional promic to 13 and 13 - 6 = 7.
		

Crossrefs

Other distance to nearest: A081134, A053646, A201053.

Programs

  • Python
    def a(n): return min(abs(n-k*(k+1)*(k+2)) for k in range(int(n**1/3)+1))
    print([a(n) for n in range(78)]) # Michael S. Branicky, Mar 28 2021

A342873 Numbers whose distance to the nearest cube equals the distance to the nearest product of 3 consecutive integers (three-dimensional oblong).

Original entry on oeis.org

0, 7, 16, 62, 92, 213, 276, 508, 616, 995, 1160, 1722, 1956, 2737, 3052, 4088, 4496, 5823, 6336, 7990, 8620, 10637, 11396, 13812, 14712, 17563, 18616, 21938, 23156, 26985, 28380, 32752, 34336, 39287, 41072, 46638, 48636, 54853, 57076, 63980, 66440, 74067
Offset: 1

Views

Author

Lamine Ngom, Mar 28 2021

Keywords

Comments

That is, numbers k such that A074989(k) = A342872(k).
They form 2 partitions:
7, 62, 213, ... = 8*k^3 - k = k*A157914(k).
0, 16, 92, ... = 8*k^3 + 6*k^2 + 2*k = 2*k*A033951(k).

Crossrefs

Programs

  • Python
    def aupto(limit):
      cubes = [k**3 for k in range(int((limit+1)**1/3)+2)]
      proms = [k*(k+1)*(k+2) for k in range(int((limit+1)**1/3)+1)]
      A074989 = [min(abs(n-c) for c in cubes) for n in range(limit+1)]
      A342872 = [min(abs(n-p) for p in proms) for n in range(limit+1)]
      return [m for m in range(limit+1) if A074989[m] == A342872[m]]
    print(aupto(10**4)) # Michael S. Branicky, Mar 28 2021

A343766 Lexicographically earliest sequence of distinct integers such that a(0) = 0 and the balanced ternary expansions of two consecutive terms differ by a single digit, as far to the right as possible.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Apr 28 2021

Keywords

Comments

This sequence has similarities with A003188 and with A341055.
A007949 gives the positions of the digit that is altered from one term to the other.
To compute a(n):
- consider the ternary representation of A128173(n),
- replace 1's by -1's and 2's by 1's,
- convert back to decimal.

Examples

			The first terms, alongside their balanced ternary expansion (with T's denoting -1's), are:
  n   a(n)  bter(a(n))
  --  ----  ----------
   0     0           0
   1    -1           T
   2     1           1
   3    -2          T1
   4    -4          TT
   5    -3          T0
   6     3          10
   7     2          1T
   8     4          11
   9    -5         T11
  10    -7         T1T
  11    -6         T10
  12   -12         TT0
  13   -13         TTT
  14   -11         TT1
		

Crossrefs

Programs

  • PARI
    See Links section.

Formula

a(n) = -A117966(A128173(n)).
Sum_{k=0..n-1} sign(a(k)) = -A081134(n).
Sum_{k=0..n} a(k) = 0 iff n belongs to A024023.
Showing 1-9 of 9 results.