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 32 results. Next

A106836 First differences of A060833 and (from a(2) onward) also of A091067 and A255068.

Original entry on oeis.org

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

Views

Author

Ralf Stephan, May 03 2005

Keywords

Comments

From Antti Karttunen, Feb 20 2015: (Start)
Among the terms a(1) .. a(8192), 1 occurs 4095 times, 2 occurs 1024 times, 3 occurs 2048 times and 4 occurs 1025 times. No larger numbers can ever occur.
That these are the first differences of not just A091067 and A255068, but also of A060833 follows from N. Sato's Feb 12 2013 comment in the latter that "For n > 1, n is in the sequence (A060833) if and only if A038189(n-1) = 1."
Also length of runs in A236840 and A255070.
(End)

Crossrefs

Programs

Formula

a(1) = 3, and for n > 1: a(n) = A091067(n) - A091067(n-1). - Antti Karttunen, Feb 20 2015

Extensions

Name edited by Antti Karttunen, Feb 20 2015

A005940 The Doudna sequence: write n-1 in binary; power of prime(k) in a(n) is # of 1's that are followed by k-1 0's.

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 9, 8, 7, 10, 15, 12, 25, 18, 27, 16, 11, 14, 21, 20, 35, 30, 45, 24, 49, 50, 75, 36, 125, 54, 81, 32, 13, 22, 33, 28, 55, 42, 63, 40, 77, 70, 105, 60, 175, 90, 135, 48, 121, 98, 147, 100, 245, 150, 225, 72, 343, 250, 375, 108, 625, 162, 243, 64, 17, 26, 39
Offset: 1

Views

Author

Keywords

Comments

A permutation of the natural numbers. - Robert G. Wilson v, Feb 22 2005
Fixed points: A029747. - Reinhard Zumkeller, Aug 23 2006
The even bisection, when halved, gives the sequence back. - Antti Karttunen, Jun 28 2014
From Antti Karttunen, Dec 21 2014: (Start)
This irregular table can be represented as a binary tree. Each child to the left is obtained by applying A003961 to the parent, and each child to the right is obtained by doubling the parent:
1
|
...................2...................
3 4
5......../ \........6 9......../ \........8
/ \ / \ / \ / \
/ \ / \ / \ / \
/ \ / \ / \ / \
7 10 15 12 25 18 27 16
11 14 21 20 35 30 45 24 49 50 75 36 125 54 81 32
etc.
Sequence A163511 is obtained by scanning the same tree level by level, from right to left. Also in binary trees A253563 and A253565 the terms on level of the tree are some permutation of the terms present on the level n of this tree. A252464(n) gives the distance of n from 1 in all these trees.
A252737(n) gives the sum and A252738(n) the product of terms on row n (where 1 is on row 0, 2 on row 1, 3 and 4 on row 2, etc.). A252745(n) gives the number of nodes on level n whose left child is larger than the right child, A252750 the difference between left and right child for each node from node 2 onward.
(End)
-A008836(a(1+n)) gives the corresponding numerator for A323505(n). - Antti Karttunen, Jan 19 2019
(a(2n+1)-1)/2 [= A244154(n)-1, for n >= 0] is a permutation of the natural numbers. - George Beck and Antti Karttunen, Dec 08 2019
From Peter Munn, Oct 04 2020: (Start)
Each term has the same even part (equivalently, the same 2-adic valuation) as its index.
Using the tree depicted in Antti Karttunen's 2014 comment:
Numbers are on the right branch (4 and descendants) if and only if divisible by the square of their largest prime factor (cf. A070003).
Numbers on the left branch, together with 2, are listed in A102750.
(End)
According to Kutz (1981), he learned of this sequence from American mathematician Byron Leon McAllister (1929-2017) who attributed the invention of the sequence to a graduate student by the name of Doudna (first name Paul?) in the mid-1950's at the University of Wisconsin. - Amiram Eldar, Jun 17 2021
From David James Sycamore, Sep 23 2022: (Start)
Alternative (recursive) definition: If n is a power of 2 then a(n)=n. Otherwise, if 2^j is the greatest power of 2 not exceeding n, and if k = n - 2^j, then a(n) is the least m*a(k) that has not occurred previously, where m is an odd prime.
Example: Use recursion with n = 77 = 2^6 + 13. a(13) = 25 and since 11 is the smallest odd prime m such that m*a(13) has not already occurred (see a(27), a(29),a(45)), then a(77) = 11*25 = 275. (End)
The odd bisection, when transformed by replacing all prime(k)^e in a(2*n - 1) with prime(k-1)^e, returns a(n), and thus gives the sequence back. - David James Sycamore, Sep 28 2022

Examples

			From _N. J. A. Sloane_, Aug 22 2022: (Start)
Let c_i = number of 1's in binary expansion of n-1 that have i 0's to their right, and let p(j) = j-th prime.  Then a(n) = Product_i p(i+1)^c_i.
If n=9, n-1 is 1000, c_3 = 1, a(9) = p(4)^1 = 7.
If n=10, n-1 = 1001, c_0 = 1, c_2 = 1, a(10) = p(1)*p(3) = 2*5 = 10.
If n=11, n-1 = 1010, c_1 = 1, c_2 = 1, a(11) = p(2)*p(3) = 15. (End)
		

References

  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A103969. Inverse is A005941 (A156552).
Cf. A125106. [From Franklin T. Adams-Watters, Mar 06 2010]
Cf. A252737 (gives row sums), A252738 (row products), A332979 (largest on row).
Related permutations of positive integers: A163511 (via A054429), A243353 (via A006068), A244154, A253563 (via A122111), A253565, A332977, A334866 (via A225546).
A000120, A003602, A003961, A006519, A053645, A070939, A246278, A250246, A252753, A253552 are used in a formula defining this sequence.
Formulas for f(a(n)) are given for f = A000265, A003963, A007949, A055396, A056239.
Numbers that occur at notable sets of positions in the binary tree representation of the sequence: A000040, A000079, A002110, A070003, A070826, A102750.
Cf. A106737, A290077, A323915, A324052, A324054, A324055, A324056, A324057, A324058, A324114, A324335, A324340, A324348, A324349 for various number-theoretical sequences applied to (i.e., permuted by) this sequence.
k-adic valuation: A007814 (k=2), A337821 (k=3).
Positions of multiples of 3: A091067.
Primorial deflation: A337376 / A337377.
Sum of prime indices of a(n) is A161511, reverse version A359043.
A048793 lists binary indices, ranked by A019565.
A066099 lists standard comps, partial sums A358134 (ranked by A358170).

Programs

  • Haskell
    a005940 n = f (n - 1) 1 1 where
       f 0 y _          = y
       f x y i | m == 0 = f x' y (i + 1)
               | m == 1 = f x' (y * a000040 i) i
               where (x',m) = divMod x 2
    -- Reinhard Zumkeller, Oct 03 2012
    (Scheme, with memoization-macro definec from Antti Karttunen's IntSeq-library)
    (define (A005940 n) (A005940off0 (- n 1))) ;; The off=1 version, utilizing any one of three different offset-0 implementations:
    (definec (A005940off0 n) (cond ((< n 2) (+ 1 n)) (else (* (A000040 (- (A070939 n) (- (A000120 n) 1))) (A005940off0 (A053645 n))))))
    (definec (A005940off0 n) (cond ((<= n 2) (+ 1 n)) ((even? n) (A003961 (A005940off0 (/ n 2)))) (else (* 2 (A005940off0 (/ (- n 1) 2))))))
    (define (A005940off0 n) (let loop ((n n) (i 1) (x 1)) (cond ((zero? n) x) ((even? n) (loop (/ n 2) (+ i 1) x)) (else (loop (/ (- n 1) 2) i (* x (A000040 i)))))))
    ;; Antti Karttunen, Jun 26 2014
    
  • Maple
    f := proc(n,i,x) option remember ; if n = 0 then x; elif type(n,'even') then procname(n/2,i+1,x) ; else procname((n-1)/2,i,x*ithprime(i)) ; end if; end proc:
    A005940 := proc(n) f(n-1,1,1) ; end proc: # R. J. Mathar, Mar 06 2010
  • Mathematica
    f[n_] := Block[{p = Partition[ Split[ Join[ IntegerDigits[n - 1, 2], {2}]], 2]}, Times @@ Flatten[ Table[q = Take[p, -i]; Prime[ Count[ Flatten[q], 0] + 1]^q[[1, 1]], {i, Length[p]}] ]]; Table[ f[n], {n, 67}] (* Robert G. Wilson v, Feb 22 2005 *)
    Table[Times@@Prime/@(Join@@Position[Reverse[IntegerDigits[n,2]],1]-Range[DigitCount[n,2,1]]+1),{n,0,100}] (* Gus Wiseman, Dec 28 2022 *)
  • PARI
    A005940(n) = { my(p=2, t=1); n--; until(!n\=2, n%2 && (t*=p) || p=nextprime(p+1)); t } \\ M. F. Hasler, Mar 07 2010; update Aug 29 2014
    
  • PARI
    a(n)=my(p=2, t=1); for(i=0,exponent(n), if(bittest(n,i), t*=p, p=nextprime(p+1))); t \\ Charles R Greathouse IV, Nov 11 2021
    
  • Python
    from sympy import prime
    import math
    def A(n): return n - 2**int(math.floor(math.log(n, 2)))
    def b(n): return n + 1 if n<2 else prime(1 + (len(bin(n)[2:]) - bin(n)[2:].count("1"))) * b(A(n))
    print([b(n - 1) for n in range(1, 101)]) # Indranil Ghosh, Apr 10 2017
    
  • Python
    from math import prod
    from itertools import accumulate
    from collections import Counter
    from sympy import prime
    def A005940(n): return prod(prime(len(a)+1)**b for a, b in Counter(accumulate(bin(n-1)[2:].split('1')[:0:-1])).items()) # Chai Wah Wu, Mar 10 2023

Formula

From Reinhard Zumkeller, Aug 23 2006, R. J. Mathar, Mar 06 2010: (Start)
a(n) = f(n-1, 1, 1)
where f(n, i, x) = x if n = 0,
= f(n/2, i+1, x) if n > 0 is even
= f((n-1)/2, i, x*prime(i)) otherwise. (End)
From Antti Karttunen, Jun 26 2014: (Start)
Define a starting-offset 0 version of this sequence as:
b(0)=1, b(1)=2, [base cases]
and then compute the rest either with recurrence:
b(n) = A000040(1+(A070939(n)-A000120(n))) * b(A053645(n)).
or
b(2n) = A003961(b(n)), b(2n+1) = 2 * b(n). [Compare this to the similar recurrence given for A163511.]
Then define a(n) = b(n-1), where a(n) gives this sequence A005940 with the starting offset 1.
Can be also defined as a composition of related permutations:
a(n+1) = A243353(A006068(n)).
a(n+1) = A163511(A054429(n)). [Compare the scatter plots of this sequence and A163511 to each other.]
This permutation also maps between the partitions as enumerated in the lists A125106 and A112798, providing identities between:
A161511(n) = A056239(a(n+1)). [The corresponding sums ...]
A243499(n) = A003963(a(n+1)). [... and the products of parts of those partitions.]
(End)
From Antti Karttunen, Dec 21 2014 - Jan 04 2015: (Start)
A002110(n) = a(1+A002450(n)). [Primorials occur at (4^n - 1)/3 in the offset-0 version of the sequence.]
a(n) = A250246(A252753(n-1)).
a(n) = A122111(A253563(n-1)).
For n >= 1, A055396(a(n+1)) = A001511(n).
For n >= 2, a(n) = A246278(1+A253552(n)).
(End)
From Peter Munn, Oct 04 2020: (Start)
A000265(a(n)) = a(A000265(n)) = A003961(a(A003602(n))).
A006519(a(n)) = a(A006519(n)) = A006519(n).
a(n) = A003961(a(A003602(n))) * A006519(n).
A007814(a(n)) = A007814(n).
A007949(a(n)) = A337821(n) = A007814(A003602(n)).
a(n) = A225546(A334866(n-1)).
(End)
a(2n) = 2*a(n), or generally a(2^k*n) = 2^k*a(n). - Amiram Eldar, Oct 03 2022
If n-1 = Sum_{i} 2^(q_i-1), then a(n) = Product_{i} prime(q_i-i+1). These are the Heinz numbers of the rows of A125106. If the offset is changed to 0, the inverse is A156552. - Gus Wiseman, Dec 28 2022

Extensions

More terms from Robert G. Wilson v, Feb 22 2005
Sign in a formula switched and Maple program added by R. J. Mathar, Mar 06 2010
Binary tree illustration and keyword tabf added by Antti Karttunen, Dec 21 2014

A028983 Numbers whose sum of divisors is even.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

The even terms of this sequence are the even terms appearing in A178910. [Edited by M. F. Hasler, Oct 02 2014]
A071324(a(n)) is even. - Reinhard Zumkeller, Jul 03 2008
Sigma(a(n)) = A000203(a(n)) = A152678(n). - Jaroslav Krizek, Oct 06 2009
A083207 is a subsequence. - Reinhard Zumkeller, Jul 19 2010
Numbers k such that the number of odd divisors of k (A001227) is even. - Omar E. Pol, Apr 04 2016
Numbers k such that the sum of odd divisors of k (A000593) is even. - Omar E. Pol, Jul 05 2016
Numbers with a squarefree part greater than 2. - Peter Munn, Apr 26 2020
Equivalently, numbers whose odd part is nonsquare. Compare with the numbers whose square part is even (i.e., nonodd): these are the positive multiples of 4, A008586\{0}, and A225546 provides a self-inverse bijection between the two sets. - Peter Munn, Jul 19 2020
Also numbers whose reversed prime indices have alternating product > 1, where we define the alternating product of a sequence (y_1,...,y_k) to be Product_i y_i^((-1)^(i-1)). Also Heinz numbers of the partitions counted by A347448. - Gus Wiseman, Oct 29 2021
Numbers whose number of middle divisors is not odd (cf. A067742). - Omar E. Pol, Aug 02 2022

Crossrefs

The complement is A028982 = A000290 U A001105.
Subsequences: A083207, A091067, A145204\{0}, A225838, A225858.
Cf. A334748 (a permutation).
Related to A008586 via A225546.
Ranks the partitions counted by A347448, complement A119620.

Programs

  • Mathematica
    Select[Range[82],EvenQ[DivisorSigma[1,#]]&] (* Jayanta Basu, Jun 05 2013 *)
  • PARI
    is(n)=!issquare(n)&&!issquare(n/2) \\ Charles R Greathouse IV, Jan 11 2013
    
  • Python
    from math import isqrt
    def A028983(n):
        def f(x): return n-1+isqrt(x)+isqrt(x>>1)
        kmin, kmax = 1,2
        while f(kmax) >= kmax:
            kmax <<= 1
        while True:
            kmid = kmax+kmin>>1
            if f(kmid) < kmid:
                kmax = kmid
            else:
                kmin = kmid
            if kmax-kmin <= 1:
                break
        return kmax # Chai Wah Wu, Aug 22 2024

Formula

a(n) ~ n. - Charles R Greathouse IV, Jan 11 2013
a(n) = n + (1 + sqrt(2)/2)*sqrt(n) + O(1). - Charles R Greathouse IV, Sep 01 2015
A007913(a(n)) > 2. - Peter Munn, May 05 2020

A034947 Jacobi (or Kronecker) symbol (-1/n).

Original entry on oeis.org

1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1
Offset: 1

Views

Author

Keywords

Comments

Also the regular paper-folding sequence.
For a proof that a(n) equals the paper-folding sequence, see Allouche and Sondow, arXiv v4. - Jean-Paul Allouche and Jonathan Sondow, May 19 2015
It appears that, replacing +1 with 0 and -1 with 1, we obtain A038189. Alternatively, replacing -1 with 0 we obtain (allowing for offset) A014577. - Jeremy Gardiner, Nov 08 2004
Partial sums = A005811 starting (1, 2, 1, 2, 3, 2, 1, 2, 3, ...). - Gary W. Adamson, Jul 23 2008
The congruence in {-1,1} of the odd part of n modulo 4 (Cf. A099545). - Peter Munn, Jul 09 2022

Examples

			G.f. = x + x^2 - x^3 + x^4 + x^5 - x^6 - x^7 + x^8 + x^9 + x^10 - x^11 - x^12 + ...
		

References

  • J.-P. Allouche and J. Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, pp. 155, 182.
  • H. Cohen, Course in Computational Number Theory, p. 28.

Crossrefs

Moebius transform of A035184.
Cf. A091072 (indices of 1), A091067 (indices of -1), A371594 (indices of run starts).
The following are all essentially the same sequence: A014577, A014707, A014709, A014710, A034947, A038189, A082410. - N. J. A. Sloane, Jul 27 2012

Programs

  • Magma
    [KroneckerSymbol(-1,n): n in [1..100]]; // Vincenzo Librandi, Aug 16 2016
    
  • Maple
    with(numtheory): A034947 := n->jacobi(-1,n);
  • Mathematica
    Table[KroneckerSymbol[ -1, n], {n, 0, 100}] (* Corrected by Jean-François Alcover, Dec 04 2013 *)
  • PARI
    {a(n) = kronecker(-1, n)};
    
  • PARI
    for(n=1, 81, f=factor(n); print1((-1)^sum(s=1, omega(n), f[s, 2]*(Mod(f[s, 1], 4)==3)), ", ")); \\ Arkadiusz Wesolowski, Nov 05 2013
    
  • PARI
    a(n)=direuler(p=1,n,if(p==2,1/(1-kronecker(-4, p)*X)/(1-X),1/(1-kronecker(-4, p)*X))) /* Ralf Stephan, Mar 27 2015 */
    
  • PARI
    a(n) = if(n%2==0, a(n/2), (n+2)%4-2) \\ Peter Munn, Jul 09 2022
  • Python
    def A034947(n):
        s = bin(n)[2:]
        m = len(s)
        i = s[::-1].find('1')
        return 1-2*int(s[m-i-2]) if m-i-2 >= 0 else 1 # Chai Wah Wu, Apr 08 2021
    
  • Python
    def A034947(n): return -1 if n>>(-n&n).bit_length()&1 else 1 # Chai Wah Wu, Feb 26 2025
    

Formula

Multiplicative with a(2^e) = 1, a(p^e) = (-1)^(e*(p-1)/2) if p>2.
a(2*n) = a(n), a(4*n+1) = 1, a(4*n+3) = -1, a(-n) = -a(n). a(n) = 2*A014577(n-1)-1.
a(prime(n)) = A070750(n) for n > 1. - T. D. Noe, Nov 08 2004
This sequence can be constructed by starting with w = "empty string", and repeatedly applying the map w -> w 1 reverse(-w) [See Allouche and Shallit p. 182]. - N. J. A. Sloane, Jul 27 2012
a(n) = (-1)^A065339(n) = lambda(A097706(n)), where A065339(n) is number of primes of the form 4*m + 3 dividing n (counted with multiplicity) and lambda is Liouville's function, A008836. - Arkadiusz Wesolowski, Nov 05 2013 and Peter Munn, Jun 22 2022
Sum_{n>=1} a(n)/n = Pi/2, due to F. von Haeseler; more generally, Sum_{n>=1} a(n)/n^(2*d+1) = Pi^(2*d+1)*A000364(d)/(2^(2*d+2)-2)(2*d)! for d >= 0; see Allouche and Sondow, 2015. - Jean-Paul Allouche and Jonathan Sondow, Mar 20 2015
Dirichlet g.f.: beta(s)/(1-2^(-s)) = L(chi_2(4),s)/(1-2^(-s)). - Ralf Stephan, Mar 27 2015
a(n) = A209615(n) * (-1)^(v2(n)), where v2(n) = A007814(n) is the 2-adic valuation of n. - Jianing Song, Apr 24 2021
a(n) = 2 - A099545(n) == A000265(n) (mod 4). - Peter Munn, Jun 22 2022 and Jul 09 2022

A014707 a(4n) = 0, a(4n+2) = 1, a(2n+1) = a(n).

Original entry on oeis.org

0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0
Offset: 0

Views

Author

Keywords

Comments

The regular paper-folding (or dragon curve) sequence.
It appears that the sequence of run lengths is A088431. - Dimitri Hendriks, May 06 2010
Runs of three consecutive ones appear around positions n = 22, 46, 54, 86, 94, 118, 150, 174, 182, ..., or for n of the form 2^(k+3)*(4*t+3)-2, k >= 0, t >= 0. - Vladimir Shevelev, Mar 19 2011

References

  • Guy Melançon, Factorizing infinite words using Maple, MapleTech journal, Vol. 4, No. 1, 1997, pp. 34-42, esp. p. 36.

Crossrefs

Equals 1 - A014577, which see for further references. Also a(n) = A038189(n+1).
The following are all essentially the same sequence: A014577, A014707, A014709, A014710, A034947, A038189, A082410.

Programs

  • Haskell
    a014707 n = a014707_list !! n
    a014707_list = f 0 $ cycle [0,0,1,0] where
       f i (x:_:xs) = x : a014707 i : f (i+1) xs
    -- Reinhard Zumkeller, Sep 28 2011
    
  • Maple
    nmax:=92: for p from 0 to ceil(simplify(log[2](nmax))) do for n from 0 to ceil(nmax/(p+2))+1 do a((2*n+1)*2^p-1) := n mod 2 od: od: seq(a(n), n=0..nmax); # Johannes W. Meijer, Jan 28 2013
    # second Maple program:
    a:= proc(n) option remember;
         `if`(n::even, irem(n/2, 2), a((n-1)/2))
        end:
    seq(a(n), n=0..92);  # Alois P. Heinz, Jun 27 2022
  • Mathematica
    a[n_ /; Mod[n, 4] == 0] = 0; a[n_ /; Mod[n, 4] == 2] = 1; a[n_ /; Mod[n, 2] == 1] := a[n] = a[(n - 1)/2]; Table[a[n],{n,0,92}] (* Jean-François Alcover, May 17 2011 *)
    (1 - JacobiSymbol[-1, Range[100]])/2 (* Paolo Xausa, May 26 2024 *)
  • PARI
    a(n)=n+=1;my(h=bitand(n,-n));n=bitand(n,h<<1);n!=0; \\ Joerg Arndt, Apr 09 2021
  • Python
    def A014707(n):
        s = bin(n+1)[2:]
        m = len(s)
        i = s[::-1].find('1')
        return int(s[m-i-2]) if m-i-2 >= 0 else 0 # Chai Wah Wu, Apr 08 2021
    
  • Python
    def A014707(n): n+=1; h=n&-n; n=n&(h<<1); return int(n!=0)
    print([A014707(n) for n in range(93)]) # Michael S. Branicky, Mar 29 2024 after Joerg Arndt
    

Formula

a(A091072(n)-1) = 0; a(A091067(n)-1) = 1. - Reinhard Zumkeller, Sep 28 2011 [Adjusted to match offset by Peter Munn, Jul 01 2022]
a(n) = (1-Jacobi(-1,n+1))/2 (cf. A034947). - N. J. A. Sloane, Jul 27 2012 [Adjusted to match offset by Peter Munn, Jul 01 2022]
Set a=0, b=1, S(0)=a, S(n+1) = S(n)aF(S(n)), where F(x) reverses x and then interchanges a and b; sequence is limit S(infinity).
a((2*n+1)*2^p-1) = n mod 2, p >= 0. - Johannes W. Meijer, Jan 28 2013
Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 1/2. - Amiram Eldar, Aug 31 2024

Extensions

More terms from Scott C. Lindhurst (ScottL(AT)alumni.princeton.edu)

A091072 Positive numbers k such that the Kronecker Symbol (-1 / k) > 0.

Original entry on oeis.org

1, 2, 4, 5, 8, 9, 10, 13, 16, 17, 18, 20, 21, 25, 26, 29, 32, 33, 34, 36, 37, 40, 41, 42, 45, 49, 50, 52, 53, 57, 58, 61, 64, 65, 66, 68, 69, 72, 73, 74, 77, 80, 81, 82, 84, 85, 89, 90, 93, 97, 98, 100, 101, 104, 105, 106, 109, 113, 114, 116, 117, 121, 122, 125, 128, 129
Offset: 1

Views

Author

Ralf Stephan, Feb 22 2004

Keywords

Comments

Numbers whose odd part is of the form 4k+1. The bit to the left of the least significant bit of each term is unset. Either of form 2a(m) or 4k+1, k >= 0, 0 < m < n.
A000265(a(n)) is an element of A016813.
a(n) such that A038189(a(n)) = 0.
Numbers n such that kronecker(n, m) = kronecker(m, n) for all m. - Michael Somos, Sep 24 2005
The Dragon curve A014577 (but changing the offset to 1): (1, 1, 0, 1, 1, 0, 0, 1, 1, 1, ...) = the characteristic function of A091072. - Gary W. Adamson, Apr 11 2010
Also indices of 1 in A034947. - Jianing Song, Apr 24 2021
The terms in the sequence are the same as the terms in the odd columns of the table in A135764 with headings 4k+1: (1, 5, 9, 13...). A014577(n) = 1 if n is in that set, but A014577(n) = 0 if n is in the set of even columns in the A135764 table. - Gary W. Adamson, May 29 2021
The asymptotic density of this sequence is 1/2. - Amiram Eldar, Sep 14 2024

Examples

			x + 2*x^2 + 4*x^3 + 5*x^4 + 8*x^5 + 9*x^6 + 10*x^7 + 13*x^8 + 16*x^9 + ...
		

Crossrefs

Complement of A091067.
Cf. A000265, A014577 (characteristic function), A014707, A016813, A034947, A055975, A106841 (first of triplet), A088742 (first differences), A339597.

Programs

  • Haskell
    import Data.List (elemIndices)
    a091072 n = a091072_list !! (n-1)
    a091072_list = map (+ 1) $ elemIndices 0 a014707_list
    -- Reinhard Zumkeller, Sep 28 2011
  • Maple
    KS := (n, k) -> NumberTheory:-KroneckerSymbol(n, k):
    aList := upto -> select(n -> 0 < KS(-1, n), [seq(1..upto)]):
    aList(129);  # Peter Luschny, Mar 20 2025
  • Mathematica
    Select[ Range[129], EvenQ[ (#/2^IntegerExponent[#, 2] - 1)/2 ] & ] (* Jean-François Alcover, Feb 16 2012, after Pari *)
  • PARI
    for(n=1,200,if(((n/2^valuation(n,2)-1)/2)%2==0,print1(n",")))
    
  • PARI
    {a(n) = local(m, c); if( n<1, 0, c=1; m=1; while( cMichael Somos, Sep 24 2005 */
    
  • PARI
    a(n) = if(n=2*n-2, my(t=1); forstep(i=logint(n,2),0,-1, if(bittest(n,i)==t, n--;t=!t))); n+1; \\ Kevin Ryde, Mar 21 2021
    
  • PARI
    isok(k) = kronecker(-1, k) > 0; \\ Michel Marcus, Mar 20 2025
    

Formula

A014707(a(n) + 1) = 0. - Reinhard Zumkeller, Sep 28 2011
A055975(a(n)) > 0. - Reinhard Zumkeller, Apr 28 2012

Extensions

New name from Peter Luschny, Mar 20 2025

A038189 Bit to left of least significant 1-bit in binary expansion of n.

Original entry on oeis.org

0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1
Offset: 0

Views

Author

Fred Lunnon, Dec 11 1999

Keywords

Comments

Characteristic function of A091067.
Image, under the coding i -> floor(i/2), of the fixed point, starting with 0, of the morphism 0 -> 01, 1 -> 02, 2 -> 32, 3 -> 31. - Jeffrey Shallit, May 15 2016
Restricted to the positive integers, completely additive modulo 2. - Peter Munn, Jun 20 2022
If a(n) is defined as 1-a(-n) for all n<0, then a(n) = a(2*n), a(4*n+1) = 0, a(4*n+3) = 1 for all n in Z. - Michael Somos, Oct 05 2024

Examples

			a(6) = 1 since 6 = 110 and bit before rightmost 1 is a 1.
		

References

  • Jean-Paul Allouche and Jeffrey O. Shallit, Automatic sequences, Cambridge, 2003, sect. 5.1.6

Crossrefs

A014707(n)=a(n+1). A014577(n)=1-a(n+1).
The following are all essentially the same sequence: A014577, A014707, A014709, A014710, A034947, A038189, A082410. - N. J. A. Sloane, Jul 27 2012
Related sequences A301848, A301849, A301850. - Fred Lunnon, Mar 27 2018

Programs

  • C
    int a(int n) { return (n & ((n&-n)<<1)) ? 1 : 0; } /* from Russ Cox */
    
  • Magma
    function a (n)
      if n eq 0 then return 0; // alternatively,  return 1;
      else while IsEven(n) do n := n div 2; end while; end if;
      return n div 2 mod 2; end function;
      nlo := 0; nhi := 32;
      [a(n) : n in [nlo..nhi] ]; //  Fred Lunnon, Mar 27 2018
    
  • Maple
    A038189 := proc(n)
        option remember;
        if n = 0 then
            0 ;
        elif type(n,'even') then
            procname(n/2) ;
        elif modp(n,4) = 1 then
            0 ;
        else
            1 ;
        end if;
    end proc:
    seq(A038189(n),n=0..100) ; # R. J. Mathar, Mar 30 2018
  • Mathematica
    f[n_] := Block[{id2 = Join[{0}, IntegerDigits[n, 2]]}, While[ id2[[-1]] == 0, id2 = Most@ id2]; id2[[-2]]]; f[0] = 0; Array[f, 105, 0] (* Robert G. Wilson v, Apr 14 2009 and fixed Feb 27 2014 *)
    f[n_] := f[n] = Switch[Mod[n, 4], 0, f[n/2], 1, 0, 2, f[n/2], 3, 1]; f[0] = 0; Array[f, 105, 0] (* Robert G. Wilson v, Apr 14 2009, fixed Feb 27 2014 *)
    a[ n_] := If[n==0, 0, Mod[(n/2^IntegerExponent[n, 2]-1)/2, 2]]; (* Michael Somos, Oct 05 2024 *)
  • PARI
    {a(n) = if(n==0, 0, ((n/2^valuation(n,2)-1)/2)%2)}; /* Michael Somos, Sep 22 2005 */
    
  • PARI
    a(n) = if(n<3, 0, prod(m=1,n, kronecker(-n,m)==kronecker(m,n))) /* Michael Somos, Sep 22 2005 */
    
  • PARI
    A038189(n)=bittest(n,valuation(n,2)+1) \\ M. F. Hasler, Aug 06 2015
    
  • PARI
    a(n)=my(h=bitand(n,-n));n=bitand(n,h<<1);n!=0; \\ Joerg Arndt, Apr 09 2021
    
  • Python
    def A038189(n):
        s = bin(n)[2:]
        m = len(s)
        i = s[::-1].find('1')
        return int(s[m-i-2]) if m-i-2 >= 0 else 0 # Chai Wah Wu, Apr 08 2021
    
  • Python
    def a(n): return 1 if (n & ((n&-n)<<1)) else 0
    print([a(n) for n in range(108)]) # Michael S. Branicky, Feb 06 2025 after Russ Cox

Formula

a(0) = 0, a(2*n) = a(n) for n>0, a(4*n+1) = 0, a(4*n+3) = 1.
G.f.: Sum_{k>=0} t^3/(1-t^4), where t=x^2^k. Parity of A025480. For n >= 1, a(n) = 1/2 * (1 - (-1)^A025480(n-1)). - Ralf Stephan, Jan 04 2004 [index adjusted by Peter Munn, Jun 22 2022]
a(n) = 1 if Kronecker(-n,m)=Kronecker(m,n) for all m, otherwise a(n)=0. - Michael Somos, Sep 22 2005
a(n) = 1 iff A164677(n) < 0. - M. F. Hasler, Aug 06 2015
For n >= 1, a(n) = A065339(n) mod 2. - Peter Munn, Jun 20 2022
From A.H.M. Smeets, Mar 08 2023: (Start)
a(n+1) = 1 - A014577(n) for n >= 0.
a(n+1) = 2 - A014710(n) for n >= 0.
a(n) = (1 - A034947(n))/2 for n > 0. (End)
Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 1/2. - Amiram Eldar, Aug 30 2024

Extensions

More terms from David W. Wilson
Definition corrected by Russ Cox and Ralf Stephan, Nov 08 2004

A236840 n minus number of runs in the binary expansion of n: a(n) = n - A005811(n).

Original entry on oeis.org

0, 0, 0, 2, 2, 2, 4, 6, 6, 6, 6, 8, 10, 10, 12, 14, 14, 14, 14, 16, 16, 16, 18, 20, 22, 22, 22, 24, 26, 26, 28, 30, 30, 30, 30, 32, 32, 32, 34, 36, 36, 36, 36, 38, 40, 40, 42, 44, 46, 46, 46, 48, 48, 48, 50, 52, 54, 54, 54, 56, 58, 58, 60, 62, 62, 62, 62, 64, 64, 64
Offset: 0

Views

Author

Antti Karttunen, Apr 18 2014

Keywords

Comments

All terms are even. Used by the "number-of-runs beanstalk" sequence A255056 and many of its associated sequences.

Crossrefs

Cf. A091067 (the positions of records), A106836 (run lengths).
Cf. A255070 (terms divided by 2).

Programs

  • Maple
    A236840 := proc(n) local i, b; if n=0 then 0 else b := convert(n, base, 2); select(i -> (b[i-1]<>b[i]), [$2..nops(b)]); n-1-nops(%) fi end: seq(A236840(i), i=0..69); # Peter Luschny, Apr 19 2014
  • Mathematica
    a[n_] := n - Length@ Split[IntegerDigits[n, 2]]; a[0] = 0; Array[a, 100, 0] (* Amiram Eldar, Jul 16 2023 *)
  • Scheme
    (define (A236840 n)  (- n (A005811 n)))

Formula

a(n) = n - A005811(n) = n - A000120(A003188(n)).
a(n) = 2*A255070(n).

A002516 Earliest sequence with a(a(n)) = 2n.

Original entry on oeis.org

0, 3, 6, 2, 12, 7, 4, 10, 24, 11, 14, 18, 8, 15, 20, 26, 48, 19, 22, 34, 28, 23, 36, 42, 16, 27, 30, 50, 40, 31, 52, 58, 96, 35, 38, 66, 44, 39, 68, 74, 56, 43, 46, 82, 72, 47, 84, 90, 32, 51, 54, 98, 60, 55, 100, 106, 80, 59, 62, 114, 104, 63, 116, 122, 192, 67, 70, 130
Offset: 0

Views

Author

Keywords

Crossrefs

Programs

  • Haskell
    import Data.List (transpose)
    a002516 n = a002516_list !! n
    a002516_list = 0 : concat (transpose
    [a004767_list, f a002516_list, a017089_list, g $ drop 2 a002516_list])
    where f [z] = []; f (_:z:zs) = 2 * z : f zs
    g [z] = [z]; g (z:_:zs) = 2 * z : g zs
    -- Reinhard Zumkeller, Jun 08 2015
  • Mathematica
    a[0] = 0; a[n_ /; Mod[n, 2] == 0] := a[n] = 2*a[n/2]; a[n_ /; Mod[n, 4] == 1] := n+2; a[n_ /; Mod[n, 4] == 3] := 2(n-2); Table[a[n], {n, 0, 67}] (* Jean-François Alcover, Feb 06 2012, after Henry Bottomley *)
  • PARI
    v2(n)=valuation(n,2)
    a(n)=2^v2(n)*(-1+3/2*n/2^v2(n)-(-3+1/2*n/2^v2(n))*(-1)^((n/2^v2(n)-1)/2))
    
  • PARI
    a(n)=local(t); if(n<1,0,if(n%2==0,2*a(n/2),t=(n-1)/2; 3*t+1/2-(t-5/2)*(-1)^t)) \\ Ralf Stephan, Feb 22 2004
    

Formula

a(4n) = 2*(a(2n)), a(4n+1) = 4n+3, a(4n+2) = 2*(a(2n+1)), a(4n+3) = 8n+2. - Henry Bottomley, Apr 27 2000
From Ralf Stephan, Feb 22 2004: (Start)
a(n) = n + 2*A006519(n) if odd part of n is of form 4k+1, or 2n - 4*A006519(n) otherwise.
a(2n) = 2*a(n), a(2n+1) = 2n + 3 + (2n - 5)*[n mod 2].
G.f.: Sum_{k>=0} 2^k*t(6t^6 + t^4 + 2t^2 + 3)/(1 - t^4)^2, t = x^2^k. (End)

A255327 a(n) = 0 if n is in the infinite trunk of "number-of-runs beanstalk" (one of the terms of A255056), otherwise number of nodes (including leaves and the node n itself) in that finite subtree of the beanstalk.

Original entry on oeis.org

0, 1, 0, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 0, 1, 5, 1, 0, 1, 2, 1, 0, 1, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 3, 1, 0, 1, 2, 1, 4, 1, 0, 1, 2, 1, 0, 1, 5, 1, 0, 1, 2, 1, 0, 1, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 3, 1, 0, 1, 2, 1, 10, 1, 0, 1, 8, 1, 0, 1, 3, 1, 2, 1, 0, 1, 2, 1, 4, 1, 0, 1, 2, 1, 0, 1, 0, 1, 3, 1, 0, 1, 2, 1, 4, 1, 0, 1, 2, 1, 0, 1, 5, 1, 0, 1, 2, 1, 0
Offset: 0

Views

Author

Antti Karttunen, Feb 21 2015

Keywords

Comments

The edge-relation between nodes is given by A236840(child) = parent. a(n) = 1 + the size of transitive closure of all children emanating from the parent at n. For any n in A255056 this would be infinite, thus such n are marked with zeros.
Odd numbers are leaves, as there are no such k that A236840(k) were odd, thus a(2n+1) = 1.

Crossrefs

Formula

a(2n+1) = 1, and for even numbers 2n, if A255339(n) = 1, then a(2n) = 0, otherwise, a(2n) = 1 + sum_{k = A091067(n) .. A255068(n)} a(k).
Showing 1-10 of 32 results. Next