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

A292266 Restricted growth sequence transform of A292265; a filter related to Shevelev's algorithm for computing A002326.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Oct 02 2017

Keywords

Comments

For all i, j: a(i) = a(j) => A002326(i) = A002326(j).

Crossrefs

Programs

  • PARI
    allocatemem(2^30);
    rgs_transform(invec) = { my(om = Map(), outvec = vector(length(invec)), u=1); for(i=1, length(invec), if(mapisdefined(om,invec[i]), my(pp = mapget(om, invec[i])); outvec[i] = outvec[pp] , mapput(om,invec[i],i); outvec[i] = u; u++ )); outvec; };
    write_to_bfile(start_offset,vec,bfilename) = { for(n=1, length(vec), write(bfilename, (n+start_offset)-1, " ", vec[n])); }
    A000265(n) = (n >> valuation(n, 2));
    A019565(n) = {my(j,v); factorback(Mat(vector(if(n, #n=vecextract(binary(n), "-1..1")), j, [prime(j), n[j]])~))}; \\ This function from M. F. Hasler
    A292265(n) = { my(x = n+n+1, z = A019565(valuation(1+x,2)), m = A000265(1+x)); while(m!=1, z *= A019565(valuation(x+m,2)); m = A000265(x+m)); z; };
    write_to_bfile(0,rgs_transform(vector(32769,n,A292265(n-1))),"b292266_upto32768.txt");

A002326 Multiplicative order of 2 mod 2n+1.

Original entry on oeis.org

1, 2, 4, 3, 6, 10, 12, 4, 8, 18, 6, 11, 20, 18, 28, 5, 10, 12, 36, 12, 20, 14, 12, 23, 21, 8, 52, 20, 18, 58, 60, 6, 12, 66, 22, 35, 9, 20, 30, 39, 54, 82, 8, 28, 11, 12, 10, 36, 48, 30, 100, 51, 12, 106, 36, 36, 28, 44, 12, 24, 110, 20, 100, 7, 14, 130, 18, 36, 68, 138, 46, 60, 28
Offset: 0

Views

Author

Keywords

Comments

In other words, least m > 0 such that 2n+1 divides 2^m-1.
Number of riffle shuffles of 2n+2 cards required to return a deck to initial state. A riffle shuffle replaces a list s(1), s(2), ..., s(m) with s(1), s((i/2)+1), s(2), s((i/2)+2), ... a(1) = 2 because a riffle shuffle of [1, 2, 3, 4] requires 2 iterations [1, 2, 3, 4] -> [1, 3, 2, 4] -> [1, 2, 3, 4] to restore the original order.
Concerning the complexity of computing this sequence, see for example Bach and Shallit, p. 115, exercise 8.
It is not difficult to prove that if 2n+1 is a prime then 2n is a multiple of a(n). But the converse is not true. Indeed, one can prove that a(2^(2t-1))=4t. Thus if n=2^(2t-1), where, for any m > 0, t=2^(m-1) then 2n is a multiple of a(n) while 2n+1 is a Fermat number which, as is well known, is not always a prime. It is an interesting problem to describe all composite numbers for which 2n is divisible by a(n). - Vladimir Shevelev, May 09 2008
For an algorithm of calculation of a(n) see author's comment in A179680. - Vladimir Shevelev, Jul 21 2010
From V. Raman, Sep 18 2012, Dec 10 2012: (Start)
If 2n+1 is prime, then the polynomial (x^(2n+1)+1)/(x+1) factors into 2n/a(n) polynomials of the same degree a(n) over GF(2).
If (x^(2n+1)+1)/(x+1) is irreducible over GF(2), then 2n+1 is prime, and 2 is a primitive root (mod 2n+1) (cf. A001122).
For all n > 0, a(n) is the degree of the largest irreducible polynomial factor for the polynomial (x^(2n+1)+1)/(x+1) over GF(2). (End)
a(n) is a factor of phi(2n+1) (A000010(2n+1)). - Douglas Boffey, Oct 21 2013
Conjecture: if p is an odd prime then a((p^3-1)/2) = p * a((p^2-1)/2). Because otherwise a((p^3-1)/2) < p * a((p^2-1)/2) iff a((p^3-1)/2) = a((p-1)/2) for a prime p. Equivalently p^3 divides 2^(p-1)-1, but no such prime p is known. - Thomas Ordowski, Feb 10 2014
A generalization of the previous conjecture: For each k>=2, if p is an odd prime then a(((p^(k+1))-1)/2) = p * a((p^k-1)/2). Computer testing of this generalized conjecture shows that there is no counterexample for k and p both up to 1000. - Ahmad J. Masad, Oct 17 2020

Examples

			From _Vladimir Shevelev_, Oct 03 2017: (Start)
Our algorithm for the calculation of a(n) in the author's comment in A179680 (see also the Sage program below) could be represented in the form of a "finite continued fraction". For example let n = 8, 2*n+1 = 17. We have
    1 + 17
    ------- + 17
       2
    ------------- + 17
           2
    ------------------- + 17
              2
    -------------------------- = 1
                 32
Here the denominators are the A006519 of the numerators: A006519(1+17) = 2, A006519(9+17) = 2, A006519(13+17) = 2, A006519(15+17) = 32. Summing the exponents of these powers of 2, we obtain the required result: a(8) = 1 + 1 + 1 + 5 = 8. Indeed, we have (((1*32 - 17)*2 - 17)*2 - 17)*2 - 17 = 1. So 32*2*2*2 - 1 == 0 (mod 17), 2^8 - 1 == 0 (mod 17). In the general case, note that all "partial fractions" (which indeed are integers) are odd residues modulo 2*n+1 in the interval [1, 2*n-1]. It is easy to prove that the first 1 appears not later than in the n-th step. (End)
		

References

  • E. Bach and Jeffrey Shallit, Algorithmic Number Theory, I.
  • T. Folger, "Shuffling Into Hyperspace," Discover, 1991 (vol 12, no 1), pages 66-67.
  • M. Gardner, "Card Shuffles," Mathematical Carnival chapter 10, pages 123-138. New York: Vintage Books, 1977.
  • L. Lunelli and M. Lunelli, Tavola di congruenza a^n == 1 mod K per a=2,5,10, Atti Sem. Mat. Fis. Univ. Modena 10 (1960/61), 219-236 (1961).
  • J. H. Silverman, A Friendly Introduction to Number Theory, 3rd ed., Pearson Education, Inc, 2006, p. 146, Exer. 21.3
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A024222, A006694 (number of cyclotomic cosets).
Cf. A014664 (order of 2 mod n-th prime).
Cf. A001122 (primes for which 2 is a primitive root).
Cf. A216838 (primes for which 2 is not a primitive root).
Bisections give A274298, A274299.
Partial sums: A359147.

Programs

  • GAP
    List([0..100],n->OrderMod(2,2*n+1)); # Muniru A Asiru, Feb 01 2019
    
  • Haskell
    import Data.List (findIndex)
    import Data.Maybe (fromJust)
    a002326 n = (+ 1) $ fromJust $
                findIndex ((== 0) . (`mod` (2 * n + 1))) $ tail a000225_list
    -- Reinhard Zumkeller, Apr 22 2013
    
  • Magma
    [ 1 ] cat [ Modorder(2, 2*n+1): n in [1..72] ]; // Klaus Brockhaus, Dec 03 2008
    
  • Maple
    a := n -> `if`(n=0, 1, numtheory:-order(2, 2*n+1)):
    seq(a(n), n=0..72);
  • Mathematica
    Table[MultiplicativeOrder[2, 2*n + 1], {n, 0, 100}] (* Robert G. Wilson v, Apr 05 2011 *)
  • PARI
    a(n)=if(n<0,0,znorder(Mod(2,2*n+1))) /* Michael Somos, Mar 31 2005 */
    
  • Python
    from sympy import n_order
    [n_order(2, 2*n+1) for n in range(73)] # Hermann Stamm-Wilbrandt, Jul 27 2021
  • Sage
    # From Peter Luschny, Oct 06 2017: (Start)
    [Mod(2,n).multiplicative_order() for n in (0..145) if gcd(n,2) == 1]
    # Algorithm from Vladimir Shevelev as described in A179680 and presented in Example.
    def A002326VS(n):
        s, m, N = 0, 1, 2*n + 1
        while True:
            k = N + m
            v = valuation(k, 2)
            s += v
            m = k >> v
            if m == 1: break
        return s
    [A002326VS(n) for n in (0..72)] # (End)
    

Formula

a((3^n-1)/2) = A025192(n). - Vladimir Shevelev, May 09 2008
Bisection of A007733: a(n) = A007733(2*n+1). - Max Alekseyev, Jun 11 2009
a((b(n)-1)/2) = n for odd n and even n such that b(n/2) != b(n), where b(n) = A005420(n). - Thomas Ordowski, Jan 11 2014
Note that a(2^n-1) = n+1 and a(2^n) = 2*(n+1). - Thomas Ordowski, Jan 16 2014
a(n) = A056239(A292239(n)) = A048675(A292265(n)). - Antti Karttunen, Oct 04 2017

Extensions

More terms from David W. Wilson, Jan 13 2000
More terms from Benoit Cloitre, Apr 11 2003

A292270 Sum of all partial fractions in the algorithm used for calculation of A002326(n).

Original entry on oeis.org

1, 1, 4, 1, 13, 25, 36, 1, 38, 81, 12, 26, 124, 121, 196, 1, 103, 73, 324, 42, 224, 175, 91, 147, 232, 14, 676, 170, 303, 841, 900, 1, 264, 1089, 385, 364, 93, 301, 585, 563, 1093, 1681, 44, 355, 152, 118, 83, 484, 1254, 763, 2500, 1043, 156, 2809, 996, 564, 952, 931, 71, 387, 3325, 176, 3124, 1, 649, 4225, 554, 1081
Offset: 0

Views

Author

Keywords

Comments

This sequence gives important additional insight into the algorithm for the calculation of A002326 (see A179680 for its description). Let us estimate how many steps are required before (the first) 1 will appear. Note that all partial fractions (which are indeed, integers) are odd residues modulo 2*n+1 from the interval [1,2*n-1]. So, if there is no repetition, then the number of steps does not exceed n. Suppose then that there is a repetition before the appearance of 1. Then for an odd residue k from [1, 2*n-1], 2^m_1 == 2^m_2 == k (mod 2*n+1) such that m_2 > m_1. But then 2^(m_2-m_1) == 1 (mod 2*n+1). So, since m_2 - m_1 < m_2, it means that 1 should appear earlier than the repetition of k, which is a contradiction. So the number of steps <= n. For example, for n=9, 2*n+1 = 19, we have exactly 9 steps with all other odd residues <= 17 modulo 19 appearing before the final 1: 5, 3, 11, 15, 17, 9, 7, 13, 1.
A001122 gives the odd numbers k such that a((k-1)/2) = A000290((k-1)/2).

Examples

			Let n = 9. According to the comment, a(9) = 5 + 3 + 11 + 15 + 17 + 9 + 7 + 13 + 1 = 81.
		

Crossrefs

Cf. A000225 (gives the positions of ones), A292938 (of squares), A292939 (and the corresponding odd numbers), A292940 (odd numbers corresponding to squares larger than one), A292379 (odd numbers corresponding to squares less than n^2).

Programs

  • PARI
    A000265(n) = (n >> valuation(n, 2));
    A006519(n) = 2^valuation(n, 2);
    A292270(n) = { my(x = n+n+1, z = ((1+x)/A006519(1+x)), m = A000265(1+x)); while(m!=1, z += ((x+m)/A006519(x+m)); m = A000265(x+m)); z; };
    
  • Scheme
    (define (A292270 n) (let ((x (+ n n 1))) (let loop ((z (/ (+ 1 x) (A006519 (+ 1 x)))) (k 1)) (let ((m (A000265 (+ x k)))) (if (= 1 m) z (loop (+ z (/ (+ x m) (A006519 (+ x m)))) m))))))

Formula

For all n >= 1, A000196(a((A001122(1+n)-1)/2)) = (A001122(1+n)-1)/2, in other words, a(A163782(n)) = A000290(A163782(n)).

A179680 The number of exponents >1 in a recursive reduction of 2n-1 until reaching an odd part equal to 1.

Original entry on oeis.org

0, 1, 1, 1, 1, 3, 3, 1, 1, 5, 1, 3, 5, 5, 7, 1, 1, 3, 9, 3, 3, 3, 3, 6, 5, 2, 13, 5, 3, 15, 15, 1, 1, 17, 5, 9, 1, 5, 7, 10, 13, 21, 1, 7, 2, 3, 2, 9, 11, 9, 25, 13, 2, 27, 9, 9, 5, 11, 2, 6, 27, 5, 25, 1, 1, 33, 3, 9, 15, 35, 11, 15, 3, 11, 37, 3, 6, 5, 13, 13
Offset: 1

Views

Author

Vladimir Shevelev, Jul 24 2010

Keywords

Comments

Let N = 2n-1. Then consider the following algorithm of updating pairs (v,m) indicating highest exponent of 2 (2-adic valuation) and odd part: Initialize at step 1 by v(1) = A007814(N+1) and m(1) = A000265(N+1). Iterate over steps i>=2: v(i) = A007814(N+m(i-1)), m(i) = A000265(N+m(i-1)) using the previous odd part m(i-1) until some m(k) = 1. a(n) is defined as the count of the v(i) which are larger than 1.
This is an algorithm to compute A002326 because the sum v(1)+v(2)+ ... +v(k) of the exponents is A002326(n-1).
A179382(n) = 1 + the number of iterations taken by the algorithm when starting from N = 2n-1. - Antti Karttunen, Oct 02 2017

Examples

			For n = 9, 2*n-1 = 17, we have v_1 = v_2 = v_3 = 1, v_4 = 5. Thus a(9) = 1.
For n = 10, 2*n-1 = 19, we have v_1 = 2, v_2 = 3, v_3 = v_4 = v_5 = 1, v_6 = v_7 = 2, v_8 = 1, v_9 = 5. Thus a(10) = 5.
		

Crossrefs

Programs

  • Maple
    A179680 := proc(n) local l,m,a ,N ; N := 2*n-1 ; a := 0 ; l := A007814(N+1) ; m := A000265(N+1) ; if l > 1 then a := a+1 ; end if; while m <> 1 do l := A007814(N+m) ; if l > 1 then a := a+1 ; end if; m := A000265(N+m) ; end do: a ; end proc:
    seq(A179680(n),n=1..80) ; # R. J. Mathar, Apr 05 2011
  • Mathematica
    a7814[n_] := IntegerExponent[n, 2];
    a265[n_] := n/2^IntegerExponent[n, 2];
    a[n_] := Module[{l, m, k, nn}, nn = 2n-1; k = 0; l = a7814[nn+1]; m = a265[nn+1]; If[l>1, k++]; While[m != 1, l = a7814[nn+m]; If[l>1, k++]; m = a265[nn+m]]; k];
    Array[a, 80] (* Jean-François Alcover, Jul 30 2018, after R. J. Mathar *)
  • Sage
    def A179680(n):
        s, m, N = 0, 1, 2*n - 1
        while True:
            k = N + m
            v = valuation(k, 2)
            if v > 1: s += 1
            m = k >> v
            if m == 1: break
        return s
    print([A179680(n) for n in (1..80)]) # Peter Luschny, Oct 07 2017
  • Scheme
    (define (A179680 n) (let ((x (+ n n -1))) (let loop ((s (- 1 (A000035 n))) (k 1)) (let ((m (A000265 (+ x k)))) (if (= 1 m) s (loop (+ s (if (> (A007814 (+ x m)) 1) 1 0)) m)))))) ;; Antti Karttunen, Oct 02 2017
    

A292239 A multiplicative encoding for the exponents of 2 obtained when using Shevelev's algorithm for computing A002326.

Original entry on oeis.org

2, 3, 10, 5, 28, 252, 840, 7, 88, 23760, 22, 330, 66528, 23760, 6652800, 11, 208, 468, 471744000, 390, 58240, 1872, 468, 163800, 93600, 39, 3736212480000, 39000, 17472, 94152554496000, 313841848320000, 13, 544, 7387354275840000, 146880, 84823200, 68, 36720, 12337920, 1079568000
Offset: 0

Views

Author

Antti Karttunen, Oct 02 2017

Keywords

Comments

a(n) = prime(v(1)) * prime(v(2)) * ... * prime(v(k)), where prime(n) is the n-th prime (= A000040(n)) and v(1) .. v(k) are 2-adic valuations (not all necessarily distinct) of the iterated values obtained when running Shevelev's algorithm for computing A002326. See comments in A179680 and compare to A292265.

Crossrefs

Programs

  • Mathematica
    a265[n_] := n/2^IntegerExponent[n, 2];
    a[n_] := Module[{x, z, m}, x = 2 n + 1; z = Prime[IntegerExponent[1 + x, 2]]; m = a265[1 + x]; While[m != 1, z *= Prime[IntegerExponent[x + m, 2]]; m = a265[x + m]]; z];
    Table[a[n], {n, 0, 39}] (* Jean-François Alcover, Oct 03 2017, translated from PARI *)
  • PARI
    A000265(n) = (n >> valuation(n, 2));
    A292239(n) = { my(x = n+n+1, z = prime(valuation(1+x,2)), m = A000265(1+x)); while(m!=1, z *= prime(valuation(x+m,2)); m = A000265(x+m)); z; };
    
  • Scheme
    (define (A292239 n) (let ((x (+ n n 1))) (let loop ((z (A000040 (A007814 (+ 1 x)))) (k 1)) (let ((m (A000265 (+ x k)))) (if (= 1 m) z (loop (* z (A000040 (A007814 (+ x m)))) m))))))

Formula

For all n >= 0:
A001222(a(n)) = A179382(1+n).
A056239(a(n)) = A002326(n).

A293445 A multiplicative encoding (base-2 compressed) for the exponents of 3 obtained when using Shevelev's algorithm for computing A053446.

Original entry on oeis.org

2, 2, 3, 12, 36, 3, 12, 24, 6, 48, 12, 20736, 82944, 12, 18, 864, 248832, 6, 20, 19906560, 59719680, 80, 8640, 720, 25920, 34560, 5, 80, 103195607040, 240, 480, 622080, 137594142720, 138240, 20, 59440669655040, 138240, 20, 14929920, 29859840, 240, 59719680, 8640, 720, 414720, 8640, 540, 447897600, 960, 46080, 34560, 59719680, 295814814232058265600, 5, 80
Offset: 1

Views

Author

Antti Karttunen, Oct 09 2017

Keywords

Examples

			A001651(5) = 7 as 7 is the fifth number not divisible by 3. According to the algorithm described in the comment of A053446 we have in the form of a "finite continued fraction"
    1 + 14
    ------ + 7
       3^1
    ---------- + 14
          3^1
    ----------------- + 7
            3^2
    ---------------------- = 1
               3^2
Cumulatively multiplying (with A019565) together the prime-numbers corresponding to 1-bits in the binary expansions of the exponents of 3 in the denominators (that are 1, 1, 2, 2, in binary 1, 1, 10, 10, with 1's in bit-positions 0 and 1), yields prime(0+1) * prime(0+1) * prime(1+1) * prime(1+1) = 2^2 * 3^2 = 36, thus a(5) = 36.
(Adapted from _Vladimir Shevelev_'s explanation in A053446.)
Another example: A001651(19) = 28 as 28 is the 19th number not divisible by 3. (1 + 28) is not a multiple of 3, so we start with (1 + 2*28) = 1+56 = 57 and proceed as:
    1 + 56
    ------ + 56                     [that is, (57/3) + 56 = 75]
       3^1
    ---------- + 56                 [that is, (75/3) + 56 = 81]
          3^1
    -----------------  = 1          [that is, (81/81) = 1]
            3^4
So we obtained exponents 1, 1, 4 (in binary "1", "1" and "100") where the 1-bits are in positions 0, 0 and 2. We form a product prime(0+1) * prime(0+1) * prime(2+1) = 2*2*5, thus a(19) = 20.
		

Crossrefs

Cf. A293446 (restricted growth transform of this sequence).
Cf. also A292265.

Programs

  • Scheme
    (define (A293445 n) (define (next_one k m) (if (zero? (modulo (+ k m) 3)) (+ k m) (+ k m m))) (let* ((u (A001651 n)) (x_init (next_one 1 u))) (let loop ((x x_init) (z (A019565 (A007949 x_init)))) (let ((r (A038502 x))) (if (= 1 r) z (let ((x_next (next_one r u))) (loop x_next (* z (A019565 (A007949 x_next))))))))))
    (define (A001651 n) (let ((x (- n 1))) (if (even? x) (+ 1 (* 3 (/ x 2))) (- (* 3 (/ (+ x 1) 2)) 1))))
    (define (A038500 n) (A000244 (A007949 n)))
    (define (A038502 n) (/ n (A038500 n)))

Formula

A048675(a(n)) = A053446(n).
Showing 1-6 of 6 results.