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-10 of 15 results. Next

A081252 Partial sums of A053646.

Original entry on oeis.org

0, 0, 1, 1, 2, 4, 5, 5, 6, 8, 11, 15, 18, 20, 21, 21, 22, 24, 27, 31, 36, 42, 49, 57, 64, 70, 75, 79, 82, 84, 85, 85, 86, 88, 91, 95, 100, 106, 113, 121, 130, 140, 151, 163, 176, 190, 205, 221, 236, 250, 263, 275, 286, 296, 305, 313, 320, 326, 331, 335, 338, 340, 341, 341
Offset: 1

Views

Author

Klaus Brockhaus, Mar 17 2003

Keywords

Examples

			First seven terms of A053646 are 0,0,1,0,1,2,1, so a(7) = 5.
		

Crossrefs

Programs

  • PARI
    {s=0; for(n=1,65,p=2^floor(0.1^25+log(n)/log(2)); print1(s=s+min(n-p,2*p-n),","))}

Formula

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

A081254 Numbers k such that A081252(m)/m^2 has a local maximum for m = k.

Original entry on oeis.org

1, 3, 6, 13, 26, 53, 106, 213, 426, 853, 1706, 3413, 6826, 13653, 27306, 54613, 109226, 218453, 436906, 873813, 1747626, 3495253, 6990506, 13981013, 27962026, 55924053, 111848106, 223696213, 447392426, 894784853, 1789569706, 3579139413
Offset: 1

Views

Author

Klaus Brockhaus, Mar 17 2003

Keywords

Comments

The limit of the local maxima, lim_{m->inf} A081252(m)/m^2 = 1/10. For local minima cf. A081253.
Row sums of the triangle A181971. - Reinhard Zumkeller, Jul 09 2012

Examples

			13 is a term since A081252(12)/12^2 = 15/144 = 0.104..., A081252(13)/13^2 = 18/169 = 0.106..., A081252(14)/14^2 = 20/196 = 0.102....
		

Crossrefs

Programs

  • Magma
    [Floor(2^(n-1)*5/3): n in [1..40]]; // Vincenzo Librandi, Apr 04 2012
    
  • Maple
    seq(floor(2^(n-1)*5/3),n=1..35); # Muniru A Asiru, Sep 20 2018
  • Mathematica
    Rest@CoefficientList[Series[-(x^2 - x - 1)*x/((x - 1)*(x + 1)*(2*x - 1)), {x, 0, 32}], x] (* Vincenzo Librandi, Apr 04 2012 *)
    a[n_]:=Floor[2^(n-1)*5/3]; Array[a,33,1] (* Stefano Spezia, Sep 01 2018 *)
  • PARI
    a(n) = 2^(n-1)*5\3; \\ Altug Alkan, Sep 21 2018

Formula

a(n) = floor(2^(n-1)*5/3). [corrected by Michel Marcus, Sep 21 2018]
a(n) = a(n-2) + 5*2^(n-3) for n > 2;
a(n+2) - a(n) = A020714(n-1);
a(n) + a(n-1) = A052549(n-1) for n > 1;
a(2*n+1) = A020989(n); a(2n) = A072197(n-1);
a(n+1) - a(n) = A048573(n-1).
G.f.: -(x^2 - x - 1)*x/((x - 1)*(x + 1)*(2*x - 1)).
a(n) = 5*2^(n-1)/3 + (-1)^n/6-1/2. a(n) = 2*a(n-1) + (1+(-1)^n)/2, a(1)=1. - Paul Barry, Mar 24 2003
a(2n) = 2*a(2*n-1) + 1, a(2*n+1) = 2*a(2*n), a(1)=1. a(n) = A000975(n-1) + 2^(n-1). - Philippe Deléham, Oct 15 2006
a(n) = A005578(n) + A000225(n-1). - Yuchun Ji, Sep 21 2018
a(n) - a(n-2) = 2 * (a(n-1) - a(n-3)), with a(0..2)=[1,3,6]. - Yuchun Ji, Mar 18 2020

A005942 a(2n) = a(n) + a(n+1), a(2n+1) = 2a(n+1), if n >= 2.

Original entry on oeis.org

1, 2, 4, 6, 10, 12, 16, 20, 22, 24, 28, 32, 36, 40, 42, 44, 46, 48, 52, 56, 60, 64, 68, 72, 76, 80, 82, 84, 86, 88, 90, 92, 94, 96, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, 156, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182
Offset: 0

Views

Author

Keywords

Comments

a(n) is the subword complexity (or factor complexity) of Thue-Morse sequence A010060, that is, the number of factors of length n in A010060. See Allouche-Shallit (2003). - N. J. A. Sloane, Jul 10 2012

References

  • J.-P. Allouche and J. Shallit, Automatic Sequences, Cambridge Univ. Press, 2003. See Problem 10, p. 335. - From N. J. A. Sloane, Jul 10 2012
  • J. Berstel et al., Combinatorics on Words: Christoffel Words and Repetitions in Words, Amer. Math. Soc., 2008. See p. 83.
  • Michel Rigo, Formal Languages, Automata and Numeration Systems, 2 vols., Wiley, 2014. Mentions this sequence - see "List of Sequences" in Vol. 2.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • Haskell
    import Data.List (transpose)
    a005942 n = a005942_list !! n
    a005942_list = 1 : 2 : 4 : 6 : zipWith (+) (drop 6 ts) (drop 5 ts) where
       ts = concat $ transpose [a005942_list, a005942_list]
    -- Reinhard Zumkeller, Nov 15 2012
  • Mathematica
    a[0] = 1; a[1] = 2; a[2] = 4; a[3] = 6; a[n_?EvenQ] := a[n] = a[n/2] + a[n/2 + 1]; a[n_?OddQ]  := a[n] = 2*a[(n + 1)/2]; Array[a,60,0] (* Jean-François Alcover, Apr 11 2011 *)
  • PARI
    a(n)=if(n<4,2*max(0,n)+(n==0),if(n%2,2*a((n+1)/2),a(n/2)+a(n/2+1)))
    

Formula

a(n) = 2*(A006165(n-1) + n - 1), n > 1.
G.f. (1+x^2)/(1-x)^2 + 2*x^2/(1-x)^2 * Sum_{k>=0} (x^2^(k+1)-x^(3*2^k)). - Ralf Stephan, Jun 04 2003
For n > 2, a(n) = 3*(n-1) + A053646(n-1). - Max Alekseyev, May 15 2011
a(n) = 2*A275202(n-1) for n > 1. - N. J. A. Sloane, Jun 04 2019

Extensions

Typo in definition corrected by Reinhard Zumkeller, Nov 15 2012

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

Original entry on oeis.org

2, 4, 9, 18, 37, 74, 149, 298, 597, 1194, 2389, 4778, 9557, 19114, 38229, 76458, 152917, 305834, 611669, 1223338, 2446677, 4893354, 9786709, 19573418, 39146837, 78293674, 156587349, 313174698, 626349397, 1252698794, 2505397589
Offset: 1

Views

Author

Klaus Brockhaus, Mar 17 2003

Keywords

Comments

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

Examples

			9 is a term since A081252(8)/8^2 = 5/64 = 0.078, A081252(9)/9^2 = 6/81 = 0.074, A081252(10)/10^2 = 8/100 = 0.080.
		

Crossrefs

Cf. A266071 (binary).

Programs

  • Mathematica
    Rest@ CoefficientList[Series[-x (x^2 - 2)/((x - 1) (x + 1) (2 x - 1)), {x, 0, 31}], x]
  • Python
    print([7*2**n//6 for n in range(1, 50)]) # Karl V. Keller, Jr., May 22 2022

Formula

a(n) = floor(2^(n-1)*7/3).
a(n) = a(n-2) + 7*2^(n-3) for n > 2; a(n+2) - a(n) = A005009(n-1); a(n+1) - a(n) = A062092(n-1).
G.f.: -x*(x^2 - 2)/((x - 1)*(x + 1)*(2*x - 1)).
a(n) = 2*a(n-1) for even n, otherwise a(n) = 2*a(n-1)+1, with a(1)=2. - Bruno Berselli, Jun 19 2014

Extensions

Formulas adjusted to be consistent with offset 1 by Pontus von Brömssen, Sep 27 2021

A081134 Distance to nearest power of 3.

Original entry on oeis.org

0, 1, 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, 19, 20, 21, 22, 23, 24, 25, 26, 27, 26, 25, 24, 23, 22, 21, 20, 19, 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
Offset: 1

Views

Author

Klaus Brockhaus, Mar 08 2003

Keywords

Examples

			a(7) = 2 since 9 is closest power of 3 to 7 and 9 - 7 = 2.
		

Crossrefs

Programs

  • Maple
    a:= n-> (h-> min(n-h, 3*h-n))(3^ilog[3](n)):
    seq(a(n), n=1..100);  # Alois P. Heinz, Mar 28 2021
  • Mathematica
    Flatten[Table[Join[Range[0,3^n],Range[3^n-1,1,-1]],{n,0,4}]] (* Harvey P. Dale, Dec 31 2013 *)
  • PARI
    a(n) = my (p=#digits(n,3)); return (min(n-3^(p-1), 3^p-n)) \\ Rémy Sigrist, Mar 24 2018
    
  • Python
    def A081134(n):
        kmin, kmax = 0,1
        while 3**kmax <= n:
            kmax *= 2
        while True:
            kmid = (kmax+kmin)//2
            if 3**kmid > n:
                kmax = kmid
            else:
                kmin = kmid
            if kmax-kmin <= 1:
                break
        return min(n-3**kmin, 3*3**kmin-n) # Chai Wah Wu, Mar 31 2021

Formula

a(n) = min(n-3^floor(log(n)/log(3)), 3*3^floor(log(n)/log(3))-n).
From Peter Bala, Sep 30 2022: (Start)
a(n) = n - A006166(n); a(n) = 2*n - A003605(n).
a(1) = 0, a(2) = 1, a(3) = 0; thereafter, a(3*n) = 3*a(n), a(3*n+1) = 2*a(n) + a(n+1) and a(3*n+2) = a(n) + 2*a(n+1). (End)

A060973 a(2*n+1) = a(n+1)+a(n), a(2*n) = 2*a(n), with a(1)=0 and a(2)=1.

Original entry on oeis.org

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

Views

Author

Henry Bottomley, May 09 2001

Keywords

Examples

			a(6) = 2*a(3) = 2*1 = 2.
a(7) = a(3) + a(4) = 1 + 2 = 3.
		

Crossrefs

Programs

  • Maple
    A060973 := proc(n)
        option remember;
        if n <= 2 then
            return n-1;
        fi;
        if n mod 2 = 0 then
            2*procname(n/2)
        else
            procname((n-1)/2)+procname((n+1)/2);
        fi;
    end proc:  # R. J. Mathar Nov 30 2014
  • Mathematica
    nn = 77; Array[Set[a[#], # - 1] &, 2]; Do[Set[a[i], If[EvenQ[i], 2 a[i/2], a[# + 1] + a[#] &[(i - 1)/2]]], {i, 3, nn}]; Array[a, nn] (* Michael De Vlieger, Mar 22 2022 *)
  • PARI
    a(n) = my(i=logint(n,2)-1); if(bittest(n,i), n - 2<Kevin Ryde, Aug 19 2022
  • Python
    from functools import lru_cache
    @lru_cache(maxsize=None)
    def A060973(n): return n-1 if n <= 2 else A060973(n//2) + A060973((n+1)//2) # Chai Wah Wu, Mar 08 2022
    

Formula

a(n) = n - A006165(n) = A006165(n) - A053646(n) = (n - A053646(n))/2 [for n > 1].
If n = 2*(2^m) + k with 0 <= k <= 2^m, then a(n) = 2^m; if n = 3*(2^m) + k with 0 <= k <= 2^m, then a(n) = 2^m + k.
G.f.: -x/(1 - x) + x/(1 - x)^2 * ( 1 + Sum_{k >= 0} t^2*(t - 1) ), t = x^(2^k). - Ralf Stephan, Sep 12 2003
Conjectures from Peter Bala, Aug 03 2022: (Start)
a(n - a(n)) = a(n - a(n - a(n - a(n)))).
If b(n) = a(a(n)) then b(n - b(n)) = b(n - b(n - b(n - b(n)))) for n >= 2. (End)
Sum_{n>=2} 1/a(n)^2 = Pi^2/6 + 2. - Amiram Eldar, Sep 08 2022

A303545 For any n > 0 and prime number p, let d_p(n) be the distance from n to the nearest p-smooth number; a(n) = Sum_{i prime} d_i(n).

Original entry on oeis.org

0, 0, 1, 0, 2, 2, 3, 0, 1, 3, 6, 4, 7, 5, 2, 0, 6, 2, 9, 6, 9, 11, 14, 8, 8, 10, 5, 6, 12, 4, 10, 0, 4, 9, 5, 4, 15, 16, 13, 12, 24, 18, 28, 18, 16, 22, 28, 16, 17, 16, 20, 20, 25, 10, 12, 12, 17, 22, 24, 8, 21, 13, 3, 0, 5, 8, 26, 18, 16, 10, 25, 8, 28, 21
Offset: 1

Views

Author

Rémy Sigrist, Apr 26 2018

Keywords

Comments

For any n > 0 and prime number p >= A006530(n), d_p(n) = 0; hence the series in the name contains only finitely many nonzero terms and is well defined.
See also A303548 for a similar sequence.

Examples

			For n = 42:
- d_2(42) = |42 - 32| = 10,
- d_3(42) = |42 - 36| = |42 - 48| = 6,
- d_5(42) = |42 - 40| = 2,
- d_p(42) = 0 for any prime number p >= 7,
- hence a(42) = 10 + 6 + 2 = 18.
		

Crossrefs

Programs

  • PARI
    gpf(n) = if (n==1, 1, my (f=factor(n)); f[#f~, 1])
    a(n) = my (v=0, pi=primepi(gpf(n))); for (d=0, oo, my (o=min(primepi(gpf(n-d)), primepi(gpf(n+d)))); if (o
    				

Formula

a(n) = 0 iff n is a power of 2.
a(2 * n) <= 2 * a(n).
a(n) >= A053646(n) + A301574(n) (as d_2 = A053646 and d_3 = A301574).

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

A301574 a(n) = distance from n to nearest 3-smooth number (A003586).

Original entry on oeis.org

0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 3, 2, 1, 0, 1, 1, 0, 1, 2, 2, 1, 0, 1, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6
Offset: 1

Views

Author

Altug Alkan and Rémy Sigrist, Mar 23 2018

Keywords

Comments

This sequence is unbounded.
A053646 is the corresponding sequence for 2-smooth numbers (A000079).

Examples

			a(20) = a(22) = 2 because 18 is the nearest 3-smooth number to 20 and 24 is the nearest 3-smooth number to 22.
		

Crossrefs

Programs

  • PARI
    \\ See Links section.
    
  • Python
    from sympy import integer_log
    def A301574(n):
        def bisection(f,kmin=0,kmax=1):
            while f(kmax) > kmax: kmax <<= 1
            while kmax-kmin > 1:
                kmid = kmax+kmin>>1
                if f(kmid) <= kmid:
                    kmax = kmid
                else:
                    kmin = kmid
            return kmax
        def f(x): return x-sum((x//3**i).bit_length() for i in range(integer_log(x,3)[0]+1))
        k = n-f(n)
        return min(n-bisection(lambda x:f(x)+k,k,k),bisection(lambda x:f(x)+k+1,n,n)-n) # Chai Wah Wu, Oct 22 2024

Formula

a(n) = 0 iff n belongs to A003586.
2 * a(n) >= a(2 * n).
3 * a(n) >= a(3 * n).

A303548 For any n > 0 and h > 0, let d_h(n) be the distance from n to the nearest number with Hamming weight at most h; a(n) = Sum_{i > 0} d_i(n).

Original entry on oeis.org

0, 0, 1, 0, 1, 2, 2, 0, 1, 2, 4, 4, 4, 4, 3, 0, 1, 2, 4, 4, 6, 8, 9, 8, 8, 8, 9, 8, 7, 6, 4, 0, 1, 2, 4, 4, 6, 8, 9, 8, 10, 12, 15, 16, 17, 18, 18, 16, 16, 16, 17, 16, 17, 18, 18, 16, 15, 14, 14, 12, 10, 8, 5, 0, 1, 2, 4, 4, 6, 8, 9, 8, 10, 12, 15, 16, 17, 18
Offset: 1

Views

Author

Rémy Sigrist, Apr 26 2018

Keywords

Comments

For any n > 0 and h >= A000120(n), d_h(n) = 0, hence the series in the name contains only finitely many nonzero terms and is well defined.
See also A303545 for a similar sequence.

Examples

			For n = 42:
- d_1(n) = |42 - 32| = 10,
- d_2(n) = |42 - 40| = 2,
- d_h(n) = 0 for any h >= 3,
- hence a(42) = 10 + 2 = 12.
		

Crossrefs

Programs

  • PARI
    a(n) = my (v=0, h=hamming weight(n)); for (d=0, oo, my (o=min(hamming weight(n-d), hamming weight(n+d))); if (o
    				

Formula

a(n) = 0 iff n is a power of 2.
Apparently, a(2 * n) = 2 * a(n).
a(n) >= A053646(n) (as d_1 = A053646).
Showing 1-10 of 15 results. Next