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: white

white's wiki page.

white has authored 108 sequences. Here are the ten most recent ones:

A375009 a(n) = smallest prime Q of a consecutive prime triple {P, Q, R} such that floor( (R-Q) * (Q-P) / 8 ) = n.

Original entry on oeis.org

7, 139, 23, 53, 1151, 89, 113, 10007, 509, 331, 91079, 479, 541, 79699, 631, 1129, 293, 211, 5557, 265621, 2633, 1259, 1599709, 3659, 1327, 2127269, 4703, 1847, 1349533, 4201, 7621, 16519, 2579, 41333, 10343761, 4621, 4327, 8039, 16729, 3433, 166209301, 3271, 44351
Offset: 1

Author

Carl R. White, Jul 27 2024

Keywords

Comments

Without taking the floor there is no such Q where (R-Q)*(Q-P)/8 = 2.
Dickson's conjecture implies that if n == 0 or 1 (mod 3) there are infinitely many primes Q such that Q - 2 is the previous prime and Q + 4 n is the next prime, and that if n == 2 (mod 3) there are infinitely many primes Q such that Q - 2 is the previous prime and Q + 4 n + 2 is the next prime. - Robert Israel, Sep 24 2024

Crossrefs

Programs

  • Maple
    N:= 50: # for a(1) .. a(N)
    V:= Vector(N): count:= 0:
    q:= 2: r:= 3:
    while count < N do
      p:= q; q:= r; r:= nextprime(r);
      v:= floor((r-q)*(q-p)/8);
      if v >= 1 and v <= N and V[v] = 0 then
        V[v]:= q; count:= count+1
      fi;
    od:
    convert(V,list); # Robert Israel, Sep 24 2024
  • Mathematica
    With[{p = Prime[Range[10^6]]}, r = (Floor[(#[[3]] - #[[2]])*(#[[2]] - #[[1]])/8]) & /@ Partition[p, 3, 1]; p[[1 + TakeWhile[FirstPosition[r, #] & /@ Range[Max[r]], ! MissingQ[#] &] // Flatten]]] (* Amiram Eldar, Sep 24 2024 *)
  • PARI
    lista(len) = {my(c = 0, v = vector(len), p1 = 2, p2 = 3, i); forprime(p3 = 5, , i = floor((p3-p2)*(p2-p1)/8); if(i > 0 && i <= len && v[i] == 0, c++; v[i] = p2; if(c==len, break)); p1 = p2; p2 = p3); v;} \\ Amiram Eldar, Sep 24 2024
    
  • Python
    from sympy import nextprime
    def A375009(n):
        p,q = 2,3
        while True:
            r = nextprime(q)
            if (r-q)*(q-p)>>3==n:
                return q
            p,q = q,r # Chai Wah Wu, Oct 21 2024

A360968 Permutation of the positive integers derived through a process of self-reference and self-editing. a(1) = 1. Other terms generated as described in Comments.

Original entry on oeis.org

1, 3, 2, 7, 4, 13, 5, 12, 22, 15, 23, 8, 6, 36, 10, 31, 40, 26, 25, 56, 16, 9, 11, 55, 19, 18, 67, 54, 28, 86, 21, 48, 42, 45, 90, 14, 20, 37, 106, 17, 95, 33, 71, 130, 34, 27, 41, 32, 91, 47, 141, 66, 73, 29, 24, 38, 94, 164, 76, 155, 57, 133, 193, 98, 92
Offset: 1

Author

Carl R. White, Feb 27 2023

Keywords

Comments

Start with all terms set to the nominal value a(n) = n.
Mark all a(n), n > 1 as "unedited", and set a pointer p = 1.
For each unedited a(n), in increasing order of n, let q = n + a(p). Look at a(q). If a(q) has previously been edited, set a(n) = a(q); otherwise, set a(n) = q. In either case, then set a(q) = n. Mark both a(n) and a(q) as "edited". Increase p by 1 and move to the next unedited a(n), etc.
Note that once the process reaches any particular unedited n, sequence terms a(1) to a(n-1) will not be edited further by the generation process and are thus fixed. Terms of the sequence for entries greater than n may have been edited, but are "in flux" and may change again until n reaches them. p necessarily lags behind n, and so any a(p) is always well fixed by the time it is needed.
In many cases the generation process merely swaps two values relative to the positive integers, but since some edited terms could be re-edited, this will cause cycles to occur.
The positions of integers in this sequence would appear to be very hard to predict without actually generating the sequence.

Examples

			When n = 2, p = 1, so q := n+a(p) = 2+a(1) = 2+1 = 3. a(3) is "unedited" so a(n) = q and a(q) = n, i.e., set a(2) = 3 and a(3) = 2.
Since a(3) was edited by this, we continue at a(4), increasing p to 2.
Now, q := n+a(p) = 4+a(2) = 4+3 = 7. a(7) is unedited, so apply a(n) = q and a(q) = n again. i.e., set a(4) = 7 and a(7) = 4
a(5) was not edited previously, so we continue there, increasing p to 3.
Next, q := n+a(p) = 5 + a(3) = 5 + 2 = 7. a(7) is a previously edited term, so rather than use a(7)'s nominal value of 7, we instead use its currently held value of 4. I.e., a(n) = a(q) and, as always, a(q) = n. Thus we set a(5) = 4 and a(7) = 5. This must be done in the right order, lest both a(n) and a(q) be set to the same value (5 in this case).
At this point, note that while 2 and 3 are swapped relative to the positive integers, 4, 5, and 7 form a 3-cycle through their respective indices.
Continuing: a(6) is not yet edited, so n := 6 and p increases to 4. a(p) = 7, so we look to a(6+7) = a(13), an unedited term, so set a(6) = 13 and a(13) = 6, etc.
It so happens that a(13) is not edited again and remains 6, but in general it is theoretically possible that an edited term a(k) may be re-edited as long as n < k.
		

Crossrefs

Inspired loosely by A005185.
Cf. A236854, which is also self-altering in generation.

Programs

  • Python
    def A360968_list(maxn):
        B,C,p,n = [1],[],1,1
        while n < maxn:
            for i in range(2*n): B.append(0)
            n = B.index(0)+1
            q = n + B[p-1]
            if B[q-1] < 1: B[n-1] = q
            else: B[n-1] = B[q-1]
            B[q-1] = n
            p += 1
        for i in range(0,len(B)):
            if B[i]>0 and i+1 <= maxn:
                C.append(B[i])
        return C # John Tyler Rascoe, Mar 04 2023

A354973 a(0)=0; for n > 0, a(n) = 2*a(n-1) if n-1 is prime, a(n-1) + 1 otherwise.

Original entry on oeis.org

0, 1, 2, 4, 8, 9, 18, 19, 38, 39, 40, 41, 82, 83, 166, 167, 168, 169, 338, 339, 678, 679, 680, 681, 1362, 1363, 1364, 1365, 1366, 1367, 2734, 2735, 5470, 5471, 5472, 5473, 5474, 5475, 10950, 10951, 10952, 10953, 21906, 21907, 43814, 43815, 43816, 43817, 87634
Offset: 0

Author

Ben White, Jun 14 2022

Keywords

Examples

			5 is prime, so a(6) = 2*a(5) = 2*9 = 18.
6 is not prime, so a(7) = a(6) + 1 = 18 + 1 = 19.
		

Crossrefs

Cf. A110299.

Programs

  • Mathematica
    a[0] = 0; a[n_] := a[n] = If[PrimeQ[n - 1], 2*a[n - 1], a[n - 1] + 1]; Array[a, 50, 0] (* Amiram Eldar, Jun 21 2022 *)
  • PARI
    a(n) = my(k=primepi(n-1)); fromdigits(primes(k),2) - 1<Kevin Ryde, Jun 22 2022
  • Python
    from sympy import isprime
    a = [0]; [a.append(2*a[-1] if isprime(n) else a[-1]+1) for n in range(48)]
    print(a) # Michael S. Branicky, Jun 21 2022
    

Formula

a(n) = A110299(k) - 2^k + n + 1, where k = primepi(n-1) and taking A110299(0) = 0. - Kevin Ryde, Jun 22 2022

A336749 Number of circular arrangements of the first n positive integers such that adjacent terms have absolute difference 1 or 4.

Original entry on oeis.org

1, 0, 1, 1, 1, 3, 2, 3, 6, 5, 10, 12, 14, 25, 27, 40, 57, 68, 104, 133, 177, 255, 324, 454, 617, 811, 1136, 1507, 2042, 2803, 3729, 5109, 6904, 9290, 12692, 17070, 23152, 31430, 42361, 57567, 77842, 105279, 142865, 193040, 261589, 354316, 479189, 649498, 878905
Offset: 5

Author

Ethan Patrick White, Aug 02 2020

Keywords

Comments

Permutations in which adjacent terms sum to a particular value is a property central to the sequences A090460, A071984, A108658, A272259, and A107929.

Crossrefs

See A079977 or A017899 for other sequences counting similar circular arrangements of positive integers.

Programs

  • Mathematica
    CoefficientList[ Series[(1 + x + x^2 + x^3 + x^4 + x^5 + x^6)/(1 + x - x^3 - x^4 - 2*x^5 - 2*x^6 - x^7 - x^8 - x^9), {x, 0, 50}], x] (* Wesley Ivan Hurt, Nov 07 2020 *)

Formula

a(n) = -a(n-1) + a(n-3) + a(n-4) + 2*a(n-5) + 2*a(n-6) + a(n-7) + a(n-8) + a(n-9) for n > 13.
G.f.: x^5*(1 + x + x^2 + x^3 + x^4 + x^5 + x^6)/(1 + x - x^3 - x^4 - 2*x^5 - 2*x^6 - x^7 - x^8 - x^9). - Stefano Spezia, Aug 03 2020

A303427 Interleaved Lucas and Fibonacci numbers.

Original entry on oeis.org

2, 0, 1, 1, 3, 1, 4, 2, 7, 3, 11, 5, 18, 8, 29, 13, 47, 21, 76, 34, 123, 55, 199, 89, 322, 144, 521, 233, 843, 377, 1364, 610, 2207, 987, 3571, 1597, 5778, 2584, 9349, 4181, 15127, 6765, 24476, 10946, 39603, 17711, 64079, 28657, 103682, 46368, 167761
Offset: 0

Author

Craig P. White, Apr 23 2018

Keywords

Examples

			a(8) = Lucas(4) = 7;
a(9) = Fibonacci(4) = 3.
		

Crossrefs

Programs

  • MATLAB
    F = zeros(1,N);
    L = ones(1,N);
    F(2) = 1;
    L(1) = 2
    for  n = 3:N
        F(n) = F(n-1) + F(n-2);
        L(n) = L(n-1) + L(n-2);
    end
    A = F;
    B = L;
    C=[B; A];
    C=C(:)';
    C
    
  • Magma
    [IsEven(n) select Lucas(n div 2) else Fibonacci((n-1) div 2): n in [0..70]]; // Vincenzo Librandi, Apr 25 2018
    
  • Maple
    a:= n-> (<<0|1>, <1|1>>^iquo(n, 2, 'r'). <<2*(1-r), 1>>)[1, 1]:
    seq(a(n), n=0..60);  # Alois P. Heinz, Apr 23 2018
  • Mathematica
    LinearRecurrence[{0, 1, 0, 1}, {2, 0, 1, 1}, 60] (* Vincenzo Librandi, Apr 25 2018 *)
    With[{nn=30},Riffle[LucasL[Range[0,nn]],Fibonacci[Range[0,nn]]]] (* Harvey P. Dale, Feb 25 2021 *)
  • PARI
    a(n) = if(n%2, fibonacci(n\2), fibonacci(n/2-1)+fibonacci(n/2+1)); \\ Altug Alkan, Apr 25 2018

Formula

a(n) = a(n-2) + a(n-4).
G.f.: -(x+1)*(x^2-2*x+2)/(x^4+x^2-1). - Alois P. Heinz, Apr 23 2018

A227864 Smallest base in which n's digital reversal is prime, or 0 if no such base exists.

Original entry on oeis.org

0, 0, 3, 2, 0, 2, 2, 2, 4, 6, 2, 2, 2, 2, 2, 3, 8, 2, 3, 3, 2, 3, 2, 2, 2, 2, 2, 9, 2, 2, 6, 2, 4, 3, 2, 3, 12, 2, 6, 3, 2, 2, 6, 2, 2, 3, 2, 2, 2, 3, 2, 9, 2, 2, 3, 2, 2, 3, 2, 4, 12, 2, 2, 3, 12, 3, 6, 2, 2, 3, 10, 2, 6, 2, 2, 3, 10, 2, 26, 3, 2, 27, 2, 2
Offset: 0

Author

Carl R. White, Nov 01 2013

Keywords

Comments

0 and 1 are not prime and are single digits in all bases, so no reversal of digits can make them prime. a(n) is therefore 0 for both.
4 is not prime and so cannot be prime if reversed in any base where it is a single digit. This leaves bases 2 and 3 where, upon reversal, it is 1 and 4 respectively. Neither are prime, and so a(4) is also 0.
Conjecture 1: 0, 1 and 4 are the only values where there is no base in which a digital reversal makes a prime.
It is clear that for any prime p, a(p) cannot be zero, since a(p)=p+1 is a solution if there is none smaller.
Conjecture 2: n = 2 is the only prime p which must be represented in base p+1, i.e., trivially, as a single digit, in order for its reversal to be prime.
Corollary: Since a(n) cannot be n itself -- reversing n in base n obtains 1, which is not prime -- this would mean that for all positive n except 2, a(n) < n.
Other than its small magnitude, a(n) = 2 occurs often due to the fact that a reversed positive binary number is guaranteed to be odd and thus stands a greater chance of being prime.
Similarly, many solutions exist solely because reversal removes all powers of the base from n, reducing the number of divisors. Thus based solely on observation:
Conjecture 3: With the restriction gcd(base,n) = 1, a(n) = 0 except for n = 2, 3 and 6k+-1, for positive integer k, i.e., terms of A038179.

Examples

			9 in base 2 is 1001, which when reversed is the same and so not prime. In base 3 it is 100, which becomes 1 when reversed and also not prime. Base 4: 21 -> 12 (6 decimal), not prime; Base 5: 14 -> 41 (21 decimal), not prime; Base 6: 13 -> 31 (19 decimal), which is prime, so a(9) = 6, i.e., 6 is the smallest base in which 9's digital reversal is a prime number.
		

Crossrefs

Positions of 2's: A204232.

Programs

  • Python
    from sympy import isprime
    from sympy.ntheory.digits import digits
    def okb(n, b):
        return isprime(sum(d*b**i for i, d in enumerate(digits(n, b)[1:])))
    def a(n):
        for b in range(2, n+2):
            if okb(n, b): return b
        return 0
    print([a(n) for n in range(84)]) # Michael S. Branicky, Sep 06 2021

A229897 Alternative version of A229874 with tuple values in increasing order.

Original entry on oeis.org

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

Author

Carl R. White, Oct 04 2013

Keywords

Comments

An enumeration of all sorted k-tuples containing positive integers.
Begin with the 1-tuple (1), and then reading from the beginning of the list of k-tuples append to the list (n+1) if the k-tuple read is a 1-tuple and for all cases, append the (k+1)-tuples (1,n,...), (2,n,...), ..., (n,n,...), where n is the first element of the k-tuple that was read.
This sequence is a flattening of that process.
Other properties of this sequence are as A229874.

Examples

			Sequence begins (1), (2), (1,1), (3), (1,2), (2,2), (1,1,1), (4), etc.
		

Crossrefs

Cf. A001057. All tuples, not just sorted: A229873. Alternative version: A229874

A229896 Sizes of logical groups of the same integer in A229895.

Original entry on oeis.org

1, 1, 4, 1, 5, 27, 1, 7, 37, 256, 1, 9, 61, 369, 3125, 1, 11, 91, 671, 4651, 46656, 1, 13, 127, 1105, 9031, 70993, 823543, 1, 15, 169, 1695, 15961, 144495, 1273609, 16777216, 1, 17, 217, 2465, 26281, 269297, 2685817, 26269505, 387420489, 1, 19, 271, 3439
Offset: 1

Author

Carl R. White, Oct 03 2013

Keywords

Comments

The two ones at the start of the parent sequence represent parent and child 1-tuples in the grandparent sequence [(1) and (2) respectively], hence this sequence also starts with 1, 1 rather than 2, which would otherwise be a more sensible way to describe the pair of ones.
All other elements are effectively run-lengths of strings of the same integer in A229895.
The first occurrence of an integer, n, in the parent sequence, is the first of a run of n^n elements of value n. For later occurrences, the run length is n^k-(n-1)^k where k is the size of the k-tuple in the grandparent sequence, A229873.
The elements can be arranged into a triangle thus:
.... 1
.... 1, 4
.... 1, 5, 27
.... 1, 7, 37, 256
.... 1, 9, 61, 369, 3125
.... etc.
where the n-th line is:
.... n^1-(n-1)^1, n^2-(n-1)^2, ..., n^(k-1)-(n-1)^(k-1), n^n; 1 <= k < n
The first terms, for sufficiently large n simplifying as:
.... 1, 2n-1, 3n^2-3n+1, 4n^3-6n^2+4n-1, etc.
Row sums are first differences of A031972, and thus the cumulative sum of rows at the end of each row is A031972 itself, i.e., n*(n^n - 1)/(n-1).

Crossrefs

Programs

  • Maple
    T := proc (n, k) if k < n then n^k-(n-1)^k elif k = n then n^n else end if end proc: for n to 12 do seq(T(n, k), k = 1 .. n) end do; # yields sequence in triangular form - Emeric Deutsch, Jan 30 2017
  • bc
    /* GNU bc */ for(n=1;n<=10;n++)for(p=1;p<=n;p++){if(p==n){t=n^n}else{t=n^p-(n-1)^p};print t,","};print "...\n"

A229895 k-tuple sizes in A229873.

Original entry on oeis.org

1, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4
Offset: 1

Author

Carl R. White, Oct 03 2013

Keywords

Comments

Number k of elements to read from A229873 to obtain the next k-tuple.

Examples

			The sequence of tuples represented in A229873 begins (1), (2), (1,1), (1,2), (2,1), (2,2), (3), so this sequence begins 1, 1, 2, 2, 2, 2, 1.
		

Crossrefs

Programs

  • bc
    /* GNU bc */ for(n=1;n<=5;n++)for(k=1;k<=n;k++){if(k==n){t=n^n}else{t=n^k-(n-1)^k};for(i=1;i<=t;i++) print k,","};print "...\n"

A229873 An enumeration of all k-tuples containing positive integers.

Original entry on oeis.org

1, 2, 1, 1, 1, 2, 2, 1, 2, 2, 3, 1, 3, 2, 3, 3, 1, 3, 2, 3, 3, 1, 1, 1, 1, 1, 2, 1, 1, 3, 1, 2, 1, 1, 2, 2, 1, 2, 3, 2, 1, 1, 2, 1, 2, 2, 1, 3, 2, 2, 1, 2, 2, 2, 2, 2, 3, 3, 1, 1, 3, 1, 2, 3, 1, 3, 3, 2, 1, 3, 2, 2, 3, 2, 3, 3, 3, 1, 3, 3, 2, 3, 3, 3, 4
Offset: 1

Author

Carl R. White, Oct 01 2013

Keywords

Comments

The sequence pattern is an integer, n, followed by all k-tuples containing n, then (k+1)-tuples, etc., up to the n-tuples that have not yet appeared in the sequence. Directly before the integer n+1, therefore, we find the first occurrence of n^n n-tuples which contain the n^n permutations of 1 to n in lexicographic order. The cases n = 1 and n = 2 are degenerate as no tuples precede them; 1 is followed not by a tuple, but by 2, and 2 is followed by the tuple (1, 1), rather than (1, n) as with all other integers.
k-tuple clusters later in the sequence (k
Essentially, at each stage an n-hypercube of elements of size n is completed for each dimension up to the (n-1)-th, building on previous occurrences of the dimension, and then a hypercube for dimension n is begun to be built upon later.
Tuple sizes are in A229895.

Examples

			Sequence starts (1), (2), (1,1), (1,2), (2,1), (2,2), (3), (1,3), (2,3), (3,1), (3,2), (3,3), (1,1,1), ..., (3,3,3), (4), (1,4), etc.
		

Crossrefs

Cf. A001057. Sorted tuples only: A229874. Tuple sizes: A229895.