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-20 of 22 results. Next

A332769 Permutation of the positive integers: a(n) = A258996(A054429(n)) = A054429(A258996(n)).

Original entry on oeis.org

1, 3, 2, 5, 4, 7, 6, 13, 12, 15, 14, 9, 8, 11, 10, 21, 20, 23, 22, 17, 16, 19, 18, 29, 28, 31, 30, 25, 24, 27, 26, 53, 52, 55, 54, 49, 48, 51, 50, 61, 60, 63, 62, 57, 56, 59, 58, 37, 36, 39, 38, 33, 32, 35, 34, 45, 44
Offset: 1

Views

Author

Yosu Yurramendi, Feb 23 2020

Keywords

Comments

Sequence is self-inverse: a(a(n)) = n.
A002487(1+a(n)) = A162911(n) and A002487(a(n)) = A162912(n). So, a(n) generates the enumeration system of positive rationals based on Stern's sequence A002487 called 'drib'.
Given n, one can compute a(n) by taking into account the binary representation of n, and by flipping every second bit starting from the lowest until reaching the highest 1, which is not flipped.

Examples

			n = 23 =  10111_2
            x x
          10010_2 = 18 = a(n).
n = 33 = 100001_2
          x x x
         110100_2 = 52 = a(n).
		

Crossrefs

Similar R-programs: A258996, A284447.

Programs

  • PARI
    a(n) = bitxor(n, 2<Kevin Ryde, Mar 30 2021
  • R
    maxrow <- 6 # by choice
    a <- 1
    for(m in 0:maxrow) for(k in 0:(2^m-1)){
    a[2^(m+1)+2*k  ] <- 2*a[2^(m+1)-1-k] + 1
    a[2^(m+1)+2*k+1] <- 2*a[2^(m+1)-1-k]
    }
    a
    
  • R
    # Given n, compute a(n) by taking into account the binary representation of n
    maxblock <- 7 # by choice
    a <- c(1, 3, 2)
    for(n in 4:2^maxblock){
      ones <- which(as.integer(intToBits(n)) == 1)
      nbit <- as.integer(intToBits(n))[1:tail(ones, n = 1)]
      anbit <- nbit
      anbit[seq(1, length(anbit) - 1, 2)] <- 1 - anbit[seq(1, length(anbit) - 1, 2)]
      a <- c(a, sum(anbit*2^(0:(length(anbit) - 1))))
    }
    a
    # Yosu Yurramendi, Mar 30 2021
    

Formula

a(A054429(n)) = A054429(a(n)) = A258996(n),
a(A258996(n)) = A258996(a(n)) = A054429(n).
a(n) = A284447(A065190(n)) = A065190(A284447(n)),
a(A065190(n)) = A065190(a(n)) = A284447(n),
a(A284447(n)) = A284447(a(n)) = A065190(n).
a(A231551(n)) = A154437(n), a(A154437(n)) = A231551(n).
a(A153154(n)) = A284459(n), a(A284459(n)) = A153154(n).
a(1) = 1, a(2) = 3, a(3) = 2; for n > 3, a(2*n) = 2*a(A054429(n)) + 1, a(2*n+1) = 2*a(A054429(n)).
a(1) = 1; for m >= 0 and 0 <= k < 2^m, a(2^(m+1)+2*k) = 2*a(2^(m+1)-1-k) + 1, a(2^(m+1)+2*k+1) = 2*a(2^(m+1)-1-k).

A065168 Permutation t->t-1 of Z, folded to N.

Original entry on oeis.org

3, 1, 5, 2, 7, 4, 9, 6, 11, 8, 13, 10, 15, 12, 17, 14, 19, 16, 21, 18, 23, 20, 25, 22, 27, 24, 29, 26, 31, 28, 33, 30, 35, 32, 37, 34, 39, 36, 41, 38, 43, 40, 45, 42, 47, 44, 49, 46, 51, 48, 53, 50, 55, 52, 57, 54, 59, 56, 61, 58, 63, 60, 65, 62, 67, 64, 69, 66, 71, 68, 73, 70
Offset: 1

Views

Author

Antti Karttunen, Oct 19 2001

Keywords

Comments

This permutation consists of just one cycle, which is infinite.

Crossrefs

Inverse permutation to A065164.
Obtained by composing permutations A065190 and A014681.

Programs

  • Maple
    a:= n-> n-2*(-1)^n +`if`(n=2, 1, 0):
    seq(a(n), n=1..80); # Alois P. Heinz, Mar 07 2012
  • Mathematica
    Join[{3, 1}, LinearRecurrence[{1, 1, -1}, {5, 2, 7}, 100]] (* Jean-François Alcover, Feb 28 2016 *)

Formula

Let f: Z -> N be given by f(z) = 2z if z>0 else 2|z|+1, with inverse g(z) = z/2 if z even else (1-z)/2. Then a(n) = f(g(n)-1).
G.f.: x*(3-2*x+x^4+x^2-x^3) / ((x+1)*(x-1)^2). - Alois P. Heinz, Mar 07 2012
Sum_{n>=1} (-1)^n/a(n) = 2 - log(2). - Amiram Eldar, Aug 08 2023

A086970 Fix 1, then exchange the subsequent odd numbers in pairs.

Original entry on oeis.org

1, 5, 3, 9, 7, 13, 11, 17, 15, 21, 19, 25, 23, 29, 27, 33, 31, 37, 35, 41, 39, 45, 43, 49, 47, 53, 51, 57, 55, 61, 59, 65, 63, 69, 67, 73, 71, 77, 75, 81, 79, 85, 83, 89, 87, 93, 91, 97, 95, 101, 99, 105, 103, 109, 107, 113, 111, 117, 115, 121, 119
Offset: 0

Views

Author

Paul Barry, Jul 26 2003

Keywords

Comments

Partial sums are A086955.

Crossrefs

Programs

  • Magma
    [1] cat [2*n+1-2*(-1)^n: n in [1..70]]; // Vincenzo Librandi, Jun 21 2017
    
  • Mathematica
    Join[{1}, LinearRecurrence[{1, 1, -1}, {5, 3, 9}, 60]] (* Vincenzo Librandi, Jun 21 2017 *)
  • PARI
    Vec((1+4*x-3*x^2+2*x^3)/((1+x)*(1-x)^2) + O(x^100)) \\ Michel Marcus, Jun 21 2017

Formula

G.f.: (1+4*x-3*x^2+2*x^3)/((1+x)*(1-x)^2).
a(n) = n + abs(2 - (n + 1)*(-1)^n). - Lechoslaw Ratajczak, Dec 09 2016
a(n) = 2*A065190(n+1)-1 and a(n) = 2*A014681(n)+1. - Michel Marcus, Dec 10 2016
From Guenther Schrack, Jun 09 2017: (Start)
a(n) = 2*n + 1 - 2*(-1)^n for n > 0.
a(n) = 2*n + 1 - 2*cos(n*Pi) for n > 0.
a(n) = 4*n - a(n-1) for n > 1.
Linear recurrence: a(n) = a(n-1) + a(n-2) - a(n-3) for n > 3.
First differences: 2 - 4*(-1)^n for n > 1; -(-1)^n*A010696(n) for n > 1.
a(n) = A065164(n+1) + n for n > 0.
a(A014681(n)) = A005408(n) for n >= 0.
a(A005408(A014681(n)) for n >= 0.
a(n) = A005408(A103889(n)) for n >= 0.
A103889(a(n)) = 2*A065190(n+1) for n >= 0.
a(2*n-1) = A004766(n) for n > 0.
a(2*n+2) = A004767(n) for n >= 0. (End)

A153153 Permutation of natural numbers: A059893-conjugate of A003188.

Original entry on oeis.org

0, 1, 3, 2, 5, 6, 7, 4, 9, 10, 15, 12, 13, 14, 11, 8, 17, 18, 23, 20, 29, 30, 27, 24, 25, 26, 31, 28, 21, 22, 19, 16, 33, 34, 39, 36, 45, 46, 43, 40, 57, 58, 63, 60, 53, 54, 51, 48, 49, 50, 55, 52, 61, 62, 59, 56, 41, 42, 47, 44, 37, 38, 35, 32, 65, 66, 71, 68, 77, 78, 75, 72
Offset: 0

Views

Author

Antti Karttunen, Dec 20 2008

Keywords

Crossrefs

Inverse: A153154. a(n) = A059893(A003188(A059893(n))).

Programs

  • R
    a <- 1
    maxlevel <- 5 # by choice
    #
    for(m in 0:maxlevel) for(k in 0:(2^m-1)){
      a[2^(m+1)+2*k  ] <- 2*a[2^(m+1)-1-k] + 1
      a[2^(m+1)+2*k+1] <- 2*a[2^m+k]
    }
    a <- c(0,a)
    # Yosu Yurramendi, Jan 25 2020

Formula

a(n) = A065190(A231550(n)). - Yosu Yurramendi, Jan 15 2020
a(1) = 1, a(2^(m+1)+2*k) = 2*a(2^(m+1)-1-k), a(2^(m+1)+2*k+1) = 2*a(2^m+k), m >= 0, 0 <= k < 2^m. - Yosu Yurramendi, Jan 25 2020

A196189 Smallest number not yet in the sequence greater than n+1 and relatively prime to n.

Original entry on oeis.org

3, 5, 7, 9, 8, 11, 10, 13, 14, 17, 15, 19, 16, 23, 22, 21, 20, 25, 24, 27, 26, 29, 28, 31, 32, 33, 34, 37, 35, 41, 36, 39, 38, 43, 44, 47, 40, 45, 46, 49, 48, 53, 50, 51, 52, 55, 54, 59, 57, 61, 56, 63, 58, 65, 62, 67, 64, 69, 66, 71, 68, 73, 74, 75, 72, 79, 70, 77, 76
Offset: 1

Views

Author

Keywords

Crossrefs

Cf. A169190, A065190 (if condition a(n) > n dropped).

Programs

  • Haskell
    a196189 n = a196189_list !! (n-1)
    a196189_list = f 1 [] where
       f n xs = x : f (n+1) (x:xs) where
         x = head [z | z <- [n+2..], z `notElem` xs, gcd z n == 1]
    -- Reinhard Zumkeller, Sep 29 2011
  • PARI
    invecn(v,n,x)=for(k=1,n,if(v[k]==x,return(k)));0
    nexta(v,n)=local(k=n+2);while(gcd(k,n)>1||invecn(v,n-1,k),k++);k
    al(n)=local(v=vector(n));for(k=1,n,v[k]=nexta(v,k));v
    

A207800 Permutation of positive numbers. See comments.

Original entry on oeis.org

1, 2, 3, 4, 7, 8, 5, 16, 15, 32, 6, 64, 11, 128, 9, 256, 31, 512, 10, 1024, 13, 2048, 12, 4096, 23, 8192, 17, 16384, 14, 32768, 18, 65536, 63, 131072, 20, 262144, 19, 524288, 24, 1048576, 27, 2097152, 33, 4194304, 21, 8388608, 34, 16777216, 47, 33554432, 36, 67108864, 22, 134217728, 40
Offset: 1

Views

Author

Keywords

Comments

a(1)=1; on places 2,4,6,8,... we put 2^m, m=1,2,3,..., i.e., numbers n with A000120(n)=1; on places 3,7,11,15,... we put numbers n with A000120(n)=2; on places 5,13,21,29,... we put numbers n with A000120(n)=3; etc.
For general description of the order, see comment in A207790.

Crossrefs

Cf. A207790.

Formula

a(n) = A066884(A209268(A065190(n))). Equivalently, a(n) = A067576(A249725(A065190(n))). - Ivan Neretin, Apr 30 2016

Extensions

a(30) corrected by Ivan Neretin, Apr 30 2016

A143096 a(n) = 2*a(n-1)-1, with a(1)=1, a(2)=4, a(3)=5.

Original entry on oeis.org

1, 4, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385, 32769, 65537, 131073, 262145, 524289, 1048577, 2097153, 4194305, 8388609, 16777217, 33554433, 67108865, 134217729, 268435457, 536870913, 1073741825, 2147483649, 4294967297, 8589934593
Offset: 1

Views

Author

Gary W. Adamson and Roger L. Bagula, Jul 23 2008

Keywords

Examples

			a(4) = 9 = 2*a(3) - 1 = 2*5 - 1.
a(4) = 9 = (1, 3, 3, 1) dot (1, 3, -2, 5) = (1 + 9 - 6 + 5).
		

Crossrefs

Cf. A065190.
Essentially the same as A083318, A048578 and A000051.

Programs

  • Mathematica
    Join[{1,4},NestList[2#-1&,5,40]] (* or *) Join[{1,4},LinearRecurrence[ {3,-2},{5,9},40]] (* Harvey P. Dale, Feb 18 2014 *)

Formula

Binomial transform of 0, 1, 2, -4, 9, -13, 20, -26, 35, ... (offset 0).
O.g.f.: x*(1+x-5*x^2+2*x^3)/((1-x)*(1-2*x)). a(n) = 1+2^(n-1), n>2. - R. J. Mathar, Jul 31 2008
a(n) = A048578(n-2), n>=3. - R. J. Mathar, Aug 10 2008

A268466 Smallest m > 1 such that m^m == 1 (mod n).

Original entry on oeis.org

2, 3, 2, 5, 4, 7, 6, 9, 8, 11, 5, 13, 3, 9, 4, 17, 4, 19, 9, 21, 8, 5, 22, 25, 24, 3, 26, 9, 7, 31, 6, 33, 10, 35, 6, 37, 9, 9, 8, 41, 10, 43, 6, 5, 8, 47, 46, 49, 18, 51, 4, 9, 13, 55, 12, 9, 20, 7, 29, 61, 15, 35, 8, 65, 8, 25, 22, 69, 22, 51, 5, 73, 18, 9, 26, 9, 12, 79, 24, 81
Offset: 1

Views

Author

Thomas Ordowski, Feb 05 2016

Keywords

Comments

For n > 1, a(n) <= n + (-1)^n = A065190(n).
Conjecture: a(n) = n + (-1)^n for infinitely many n.
If A002322(n) is coprime to n, then a(n) <= A002322(n).
From Robert Israel, Feb 05 2016: (Start)
For m > 1, a(n) = m iff n is a divisor of m^m - 1 that is not a divisor of k^k - 1 for 1 < k < m.
In particular, a(m^m - 1) = m.
Is there any m such that this is the only n for which a(n) = m? (End)
If n > m^m - 1, then a(n) > m. - Thomas Ordowski, Oct 20 2019

Crossrefs

Cf. A065190.

Programs

  • Maple
    f:= proc(n) local k;
    for k from 2 do if igcd(k,n) = 1 and k &^ k mod n = 1 then return k fi od
    end proc:
    2,seq(f(n),n=2..100); # Robert Israel, Feb 05 2016
  • Mathematica
    {2}~Join~Table[SelectFirst[Range[2, 1000], Mod[#^#, n] == 1 &], {n, 2, 80}] (* Michael De Vlieger, Feb 05 2016, corrected by Harvey P. Dale, Sep 10 2021 *)
    smg1[n_]:=Module[{m=2},While[PowerMod[m,m,n]!=1,m++];m]; Join[{2},Array[ smg1,80,2]] (* Harvey P. Dale, Aug 13 2021 *)
  • PARI
    a(n) = {my(m = 2); while (Mod(m,n)^m != Mod(1, n), m++); m;} \\ Michel Marcus, Feb 05 2016

Extensions

More terms from Michel Marcus, Feb 05 2016

A355278 Lower left of the Cayley table for the primes when made into a group using the bijection (2, 3, 5, 7, ...) -> (0, +1, -1, +2, ...) into (Z, +); read by rows.

Original entry on oeis.org

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

Views

Author

M. F. Hasler, Sep 08 2022

Keywords

Comments

The primes can be given the structure of a group via a bijection with the group (Z, +). The simplest such bijection is to assign the integers (0, 1, -1, 2, -2, ...) to the primes, in increasing order, i.e., the composition of the prime counting function A000720, decreased by 1, with the canonical enumeration A001057.
Since this is an abelian group, the table (an infinite square matrix) is symmetric, T(m,n) = T(n,m), and it is sufficient to list only the lower left part, m >= n >= 1.
Each row and each column (of the complete square matrix) is a permutation of the primes, as always for Cayley tables. The inverse of a prime p, for the group operation *, is found at the top of the column in which 2 appears in the row starting with p, cf. 3rd formula.
Other simple bijections from the primes into (Z, +) would be to associate the negative integers to the primes congruent to 1 (mod 4) or to those congruent to 1 (mod 3), and the nonnegative integers to the others, in increasing order.

Examples

			The correspondence of primes p with integers m is as follows:
   p |  2 |  3 |  5 |  7 | 11 | 13 | 17 | 19 | 23 | 29 | 31 | ...
  ---+----+----+----+----+----+----+----+----+----+----+----+----
   m |  0 |  1 | -1 |  2 | -2 |  3 | -3 |  4 | -4 |  5 | -5 | ...
The table of the abelian group (P, *) based on this correspondence with (Z, +) starts as follows:
  [ 2  3  5  7 11 13 17 ...]
  [ 3  7  2 13  5 19 11 ...]
  [ 5  2 11  3 17  7 23 ...]
  [ 7 13  3 19  2 29  5 ...]
  [11  5 17  2 23  3 31 ...]
  [13 19  7 29  3 37  2 ...]
  [17 11 23  5 31  2 41 ...]
  [...    ...    ...    ...]
This means that 3 * 3 = 7, 3 * 5 = 2, 3 * 7 = 13, etc.: for example, primes 3 and 7 are associated to integers 1 and 2, so 3 * 7 is the prime associated to the integer 1 + 2 = 3, which yields 13.
Since 2, associated to 0 in Z, is the neutral element in the group (P, *), the first row and column is identical to the list of the primes themselves. Therefore we do not need to show row and columns headings in addition to the first row & column of the body of the table.
Since the table is symmetric,  T(m,n) = T(n,m)  <=>  p * q = q * p, the sequence lists only the lower left part: 2; 3, 7; 5, 2, 11; 7, 13, 3, 19; ...
The list of inverses of the primes 2, 3, 5, 7, 11, ... with respect to this group operation is 2, 5, 3, 11, 7, 17, 13, ... = A000040(A065190(n)), i.e., after the initial 2, list the primes with the two members of each subsequent pair swapped: swap 3 and 5, 7 and 11, 13 and 17, etc.
		

Crossrefs

Programs

  • PARI
    A355278(m,n) = inv(f(prime(m))+f(prime(n)))
    inv(x, p)=while(!mapisdefined(INV,x,&p), mapput(INV, f(p=prime(#INV+1)), p)); p
    INV=Map(); f(p)=(p=primepi(p))\2*(-1)^(p%2)

Formula

T(m, n) = T(n, m), so only m >= n >= 1 is listed: row m has length m.
T(n, n) = A000040(A042948(n)) = A000040(A014601(n-1)+1)
T(m, 1) * T(k, 1) = 2 (neutral element of the group operation *) <=> T(k, 1) is the inverse of T(m, 1) <=> T(m, k) = 2.

A354182 Lexicographically earliest sequence of distinct nonnegative integers such that for any n >= 0, the binary expansions of n and n + a(n) have no 1's in common.

Original entry on oeis.org

0, 1, 2, 5, 4, 3, 10, 9, 8, 7, 6, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61
Offset: 0

Views

Author

Rémy Sigrist, May 18 2022

Keywords

Comments

This sequence is a self-inverse permutation of the nonnegative integers.
This sequence has similarities with A065190; here n and n + a(n) have no 1's in common, there they have no common prime factor.
Empirically:
- for n > 0, b(n) = n + a(n) is always a power of 2,
- 2^k appears A001045(k) times in sequence b.

Examples

			The first terms, alongside the binary expansions of n and n + a(n), are:
  n   a(n)  bin(n)  bin(n+a(n))
  --  ----  ------  -----------
   0     0       0            0
   1     1       1           10
   2     2      10          100
   3     5      11         1000
   4     4     100         1000
   5     3     101         1000
   6    10     110        10000
   7     9     111        10000
   8     8    1000        10000
   9     7    1001        10000
  10     6    1010        10000
  11    21    1011       100000
  12    20    1100       100000
  13    19    1101       100000
  14    18    1110       100000
  15    17    1111       100000
  16    16   10000       100000
		

Crossrefs

Programs

  • Maple
    S:= [$0..100]: R:= NULL:
    for n from 0 do
      L:= convert(n,base,2); d:= nops(L);
      found:= false;
      for i from 1 to nops(S) do
        x:= S[i];
        Lx:= convert(n+x,base,2); dx:= nops(Lx);
        if andmap(t -> Lx[t]=0 or L[t] = 0, [$1..min(d,dx)]) then
          found:= true; R:= R,x; S:=subsop(i=NULL,S); break
        fi
      od;
      if not found then break fi
    od:
    R; # Robert Israel, Jul 14 2024
  • PARI
    s=0; for (n=0, 67, for (v=0, oo, if (!bittest(s,v) && bitand(n, n+v)==0, print1 (v", "); s+=2^v; break)))
    
  • Python
    from itertools import count, islice
    def agen(): # generator of terms
        aset, k, mink = set(), 0, 1
        for n in count(1):
            aset.add(k); yield k; k = mink
            while k in aset or n&(n+k): k += 1
            while mink in aset: mink += 1
    print(list(islice(agen(), 68))) # Michael S. Branicky, May 18 2022
Previous Showing 11-20 of 22 results. Next