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.

User: Grant Garcia

Grant Garcia's wiki page.

Grant Garcia has authored 18 sequences. Here are the ten most recent ones:

A188215 Starting with an empty list, n is inserted after the a(n)th element such that the binary representations of the list's elements are always sorted lexicographically.

Original entry on oeis.org

0, 1, 2, 3, 3, 4, 6, 7, 4, 5, 7, 8, 11, 12, 14, 15, 5, 6, 8, 9, 12, 13, 15, 16, 20, 21, 23, 24, 27, 28, 30, 31, 6, 7, 9, 10, 13, 14, 16, 17, 21, 22, 24, 25, 28, 29, 31, 32, 37, 38, 40, 41, 44, 45, 47, 48, 52, 53, 55
Offset: 0

Author

Grant Garcia, Mar 24 2011

Keywords

Comments

The last occurrence of any positive n in this sequence is a(2^(n - 1)).
As the list in question expands, its initial terms converge toward A131577.
The last item of the list is always zero or an element of A075427.

Examples

			For example, an a(n) of 3 means that n should be inserted after the 3rd element of the list to keep the elements lexicographically ordered.
[] (Initial empty list)
[0] (Zero inserted at the beginning: a(0) = 0)
[0, 1] (One inserted after element 1: a(1) = 1)
[0, 1, 10] (Two inserted after element 2: a(2) = 2)
[0, 1, 10, 11] (Three inserted after element 3: a(3) = 3)
[0, 1, 10, 100, 11] (Four inserted after element 3: a(4) = 3)
		

Crossrefs

Cf. A264596.

Programs

  • Mathematica
    lst = {}; Table[s = IntegerString[n, 2]; lst = Sort[Append[lst, s]]; Position[lst, s][[1, 1]] - 1, {n, 0, 63}] (* T. D. Noe, Apr 19 2011 *)
  • Python
    l = []
    for i in range(17):
        b = bin(i)[2:]
        l.append(b)
        l.sort()
        print(l.index(b))

Formula

a(2^n + b) = n + b + 1 for b = 0 or 1.
a(2^n - b) = 2^n - b for b = 1 or 2.

Extensions

Program added by Grant Garcia, Mar 30 2011
Edited by Grant Garcia, Apr 13 2011

A180625 a(1) = 2; a(n) is twice the previous term if it is prime, otherwise the previous term minus its lowest prime factor plus one.

Original entry on oeis.org

2, 4, 3, 6, 5, 10, 9, 7, 14, 13, 26, 25, 21, 19, 38, 37, 74, 73, 146, 145, 141, 139, 278, 277, 554, 553, 547, 1094, 1093, 2186, 2185, 2181, 2179, 4358, 4357, 8714, 8713, 17426, 17425, 17421, 17419, 34838, 34837, 34827
Offset: 1

Author

Grant Garcia, Jan 21 2011

Keywords

Examples

			2 is prime; 2 * 2 = 4. 4 is composite; 4 - lpf(4) + 1 = 4 - 2 + 1 = 3. 3 is prime; 3 * 2 = 6. 6 is composite; 6 - lpf(6) + 1 = 6 - 2 + 1 = 5.
		

Crossrefs

Cf. A020639.

Programs

  • Mathematica
    Join[{s=2}, Table[If[PrimeQ[s], s=2s, s=s-FactorInteger[s][[1,1]]+1]; s, {43}]]
    NestList[If[PrimeQ[#],2#,#-FactorInteger[#][[1,1]]+1]&,2,50] (* Harvey P. Dale, May 02 2012 *)

A180251 Decimal expansion of 6*(phi+1)/5, where phi is (1 + sqrt(5))/2.

Original entry on oeis.org

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

Author

Grant Garcia, Jan 16 2011

Keywords

Comments

This is an approximation to Pi.
6*(phi+1)/5 is not equal to Pi, although some have claimed this (see Dudley). - Kellen Myers, Oct 04 2013

Examples

			3.141640786499873817845504201238765741264371015766915434562538347246312555382...
		

References

  • Underwood Dudley, Mathematical Cranks, MAA 1992, pp. 247, 292.
  • Alfred S. Posamentier and Ingmar Lehmann, The (Fabulous) Fibonacci Numbers, New York, Prometheus Books, 2007, p. 119.

Crossrefs

Programs

Formula

Limit of A022089(n+2)/A022088(n) as n approaches infinity.
6*(phi + 1)/5 = 6*phi^2/5 = 3(3 + sqrt(5))/5 = 9/5 + sqrt(9/5). - Charles R Greathouse IV, Sep 13 2013
Equals 24/(5-sqrt(5))^2. - Joost Gielen, Sep 20 2013

A179997 Where records occur in A179329.

Original entry on oeis.org

2, 4, 6, 9, 15, 25, 48, 91, 169, 336, 669, 1335, 2665, 5317, 10573, 21037, 42072, 84141, 168279, 336553, 673099, 1345639, 2691276, 5382549, 10765095, 21528959, 43057916, 86115821, 172231631, 344463251, 688926491, 1377847349, 2755694696, 5511375473, 11022750944
Offset: 1

Author

Grant Garcia, Jan 13 2011

Keywords

Comments

a(n + 1) / a(n) converges to 2.

Crossrefs

Extensions

Corrected and extended by Grant Garcia, Jan 19 2011
a(30)-a(35) from Amiram Eldar, Oct 25 2024

A179329 Number of iterations of (n + lpf(n)) / 2 required to reach a prime, where lpf equals the least prime factor.

Original entry on oeis.org

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

Author

Grant Garcia, Jan 12 2011

Keywords

Comments

Zeros indicate prime indices.

Examples

			a(15) gives (15 + 3) / 2 = 9, (9 + 3) / 2 = 6, (6 + 2) / 2 = 4, (4 + 2) / 2 = 3. Four iterations were required to reach a prime, so a(15) = 4.
		

Crossrefs

Programs

  • Mathematica
    f[n_] := Length@ NestWhileList[(# + FactorInteger[#][[1, 1]])/2 &, n, ! PrimeQ@ # &] - 1; Array[f, 105, 2]

A177980 Iterate (n + lpf(n)) / 2 until a prime is reached, where lpf equals the least prime factor. a(n) is that terminating prime.

Original entry on oeis.org

2, 3, 3, 5, 3, 7, 5, 3, 3, 11, 7, 13, 5, 3, 3, 17, 3, 19, 11, 7, 7, 23, 13, 3, 5, 3, 3, 29, 3, 31, 17, 3, 3, 11, 19, 37, 11, 7, 7, 41, 7, 43, 23, 13, 13, 47, 3, 3, 5, 3, 3, 53, 3, 3, 29, 3, 3, 59, 31, 61, 17, 3, 3, 11, 3, 67, 11, 19, 19, 71, 37, 73, 11
Offset: 2

Author

Grant Garcia, Dec 16 2010

Keywords

Comments

The function (n + lpf(n)) / 2 reduces the input according to its lowest prime factor if it is composite or simply returns the input if it is prime.
Sequence contains only prime numbers (and every prime number).

Examples

			7 is prime, so (7 + lpf(7)) / 2 = (7 + 7) / 2 = 7.
15 is composite: (15 + 3) / 2 = 9, (9 + 3) / 2 = 6, (6 + 2) / 2 = 4, (4 + 2) / 2 = 3.
		

Crossrefs

Programs

  • Mathematica
    g[n_] := (n + FactorInteger[n][[1, 1]])/2; f[n_] := Last@ NestWhileList[g, n, !PrimeQ@ # &]; Array[f, 73, 2]
  • Python
    from sympy import factorint, isprime
    def a177980(n):
        while True:
            if isprime(n): return n
            else: n=int((n+A020639(n))/2)
    [a177980(n) for n in range(2, 160)] # Dumitru Damian, Dec 15 2021

A177869 Integers divisible by their number of digits in binary.

Original entry on oeis.org

1, 2, 6, 8, 12, 20, 25, 30, 36, 42, 48, 54, 60, 70, 77, 84, 91, 98, 105, 112, 119, 126, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248, 261, 270, 279, 288, 297, 306, 315, 324, 333, 342, 351, 360, 369, 378, 387, 396, 405
Offset: 1

Author

Grant Garcia, Dec 13 2010

Keywords

Examples

			105 is 1101001 in base 2 (length of 7); 105 / 7 is 15.
		

Crossrefs

Base 10 equivalent is A098952.

Programs

  • Haskell
    base_weight b g n | n == 0 = 0 | otherwise = (base_weight b g (n `div` b)) + (g $ n `mod` b)
    interesting b g = filter f [1..] where f n = n `mod` (base_weight b g n) == 0
    bin_interesting g = interesting 2 g
    weights l n | (n >=0) && ((length l) > fromInteger n) = l !! fromInteger n | otherwise = 0
    cnst = weights [1, 1]
    let sequence = bin_interesting cnst -- Victor S. Miller, Oct 17 2011
    
  • Mathematica
    Select[Range[410], IntegerQ[#/Length[IntegerDigits[#, 2]]] &] (* Alonso del Arte, Dec 13 2010 *)
  • PARI
    for(d=1, 9, forstep(n=(2^(d-1)+d-1)\d*d, 2^d-1, d, print1(n", "))) \\ Charles R Greathouse IV, Oct 17 2011
  • Python
    import math
    for n in range(1, 1000):
        if not n % int(math.log(n, 2) + 1): print(n) # Garcia
    

A181709 Indices of primes in A007310.

Original entry on oeis.org

2, 3, 4, 5, 6, 7, 8, 10, 11, 13, 14, 15, 16, 18, 20, 21, 23, 24, 25, 27, 28, 30, 33, 34, 35, 36, 37, 38, 43, 44, 46, 47, 50, 51, 53, 55, 56, 58, 60, 61, 64, 65, 66, 67, 71, 75, 76, 77, 78, 80, 81, 84, 86, 88, 90, 91, 93, 94, 95, 98, 103, 104, 105, 106, 111, 113, 116, 117, 118
Offset: 1

Author

Grant Garcia, Nov 07 2010

Keywords

Comments

All primes but 2 and 3 are present in A007310, making this sequence an efficient method for storing large quantities of primes. To unpack this sequence into primes, use the formula (6n + (-1)^n - 3) / 2.
Indices 1 and 9 (1 and 25) are the smallest nonprimes.

Examples

			A007310(2), 5, is the first prime of the sequence.
A007310(50), 149, is also a prime, hence 50 is included.
		

Crossrefs

Programs

  • Mathematica
    Floor[Prime[Range[3,80]]/3]+1 (* Harvey P. Dale, Sep 12 2019 *)
  • Python
    from sympy import isprime
    out = ""
    for n,p in enumerate(isprime((6*n+(-1)**n-3)//2) for n in range(1,1000)):
        out+=["","%s "%str(n+1)][p]
    for n,p in enumerate(out.rstrip(" ").split(" ")): print(n+1,p)

Formula

a(n) = floor(prime(n+2)/3)+1 = A144769(n+2)+1. - Gary Detlefs, Dec 11 2011
a(n) ~ n*log(n)/3. - Ilya Gutkovskiy, Jul 18 2016

A175941 Number of n-step self-avoiding walks on a line, where step X skips X - 1 spaces.

Original entry on oeis.org

1, 2, 4, 6, 10, 18, 30, 50, 78, 130, 210, 350, 586, 954, 1606, 2588, 4234, 6944, 11342, 18948, 31450, 52206, 85662, 141680, 233040, 385428, 644910, 1072074, 1783342, 2953094, 4897922, 8157096, 13571014, 22552212, 37486916, 62325564, 103508754, 172765524, 287428656, 479052200, 798944976
Offset: 0

Author

Grant Garcia, Oct 25 2010

Keywords

Examples

			a(0) = 1 because every walk must start at a specific point on the line.
   --0--
a(1) = 2 because there are two ways to start, moving one space forward or backward.
   --01-
   -10--
a(2) = 4 because there are two ways to continue each of the walks described in a(1).
   ---01-2
   --201--
   --102--
   2-10---
a(3) = 6, not 8, because two of the possible four continuations are not self-avoiding.
   ------01-2--3
   -----2013----
   --3--201-----
   -----102--3--
   ----3102-----
   3--2-10------
		

Crossrefs

Cf. A321535.

Programs

  • Maple
    b:= proc(n, s) option remember; `if`(n=0, 1, add(`if`(j in s, 0,
          b(n-1, {map(x-> x-j, s)[], 0})), j=(k->[-k, k])(nops(s))))
        end:
    a:= n-> b(n, {0}):
    seq(a(n), n=0..24);  # Alois P. Heinz, May 19 2021
  • Mathematica
    b[n_, s_] := b[n, s] = If[n == 0, 1, Sum[If[MemberQ[s, j], 0, b[n - 1, Union[Append[s - j, 0]]]], {j, {-Length[s], Length[s]}}]];
    a[n_] := b[n, {0}];
    Table[Print[n, " ", a[n]]; a[n], {n, 0, 28}] (* Jean-François Alcover, Jul 09 2021, after Alois P. Heinz *)
  • PARI
    a(n)={local(f=vectorsmall(n*(n+1)+1)); my(recurse(p, k)=if(!f[p], if(k==n, 1, f[p]=1; k++; my(z=self()(p+k, k) + self()(p-k, k)); f[p]=0; z))); recurse((#f+1)/2, 0)} \\ Andrew Howroyd, Nov 12 2018
  • Python
    x = 1
    n = 0
    runs = [[n]]
    while x < 30:
        print(x - 1, n)
        runs2 = []
        n = 0
        while runs:
            for pmx in (x, -x):
                if runs[0][ -1] + pmx not in runs[0]:
                    runs2.append(runs[0] + [runs[0][ -1] + pmx])
                    n += 1
            del runs[0]
        runs = runs2
        x += 1
    

Formula

a(n) <= 2*a(n-1) for n > 0. - Andrew Howroyd, Nov 12 2018

Extensions

a(29)-a(40) from Andrew Howroyd, Nov 12 2018

A175924 Smallest power of 2 with n repeated digits.

Original entry on oeis.org

1, 65536, 16777216, 2199023255552, 1684996666696914987166688442938726917102321526408785780068975640576
Offset: 1

Author

Grant Garcia, Oct 18 2010, Oct 20 2010

Keywords

Comments

The subsequent terms are too large to display.
a(6) and a(7), 2^971 and 2^972, respectively, both of which have 293 digits; a(8), 2^8554, has 2576 digits. a(9), 2^42485, has 12790 digits.
Corresponding exponents of 2 are 0, 16, 24, 41, 220, 971, 972, 8554, 42485, 42486, 271979. [Zak Seidov, Oct 19 2010]

Examples

			a(1) is 1 because it is the first power of 2; all integers have at least one digit.
a(2) is 65536 because it is the first power of 2 with two of the same digit in a row.
a(3) is 16777216 because it is the first power of 2 with three of the same digit in a row.
		

Crossrefs

Subsequence of A000079 (powers of 2).
Cf. A045875.

Programs

  • Mathematica
    f[n_] := Block[{k = 0}, While[ !MemberQ[Length /@ Split@ IntegerDigits[2^k], n], k++ ]; 2^k]; Table[f[n], {n, 5}] (* Robert G. Wilson v, Oct 21 2010 *)
  • Python
    import math
    for N in range(1, 10):
        repdigits = 1
        n = 0
        while repdigits < N:
            n += 1
            s = str(2 ** n)
            prev = ""
            repdigits = maxrepdigits = 1
            for d in s:
                if d == prev: repdigits += 1
                else:
                    maxrepdigits = max(maxrepdigits, repdigits)
                    repdigits = 1
                prev = d
            repdigits = max(maxrepdigits, repdigits)
        print(N, 2 ** n)