Displaying 1-10 of 20 results found.
Integers from 0 to A037834(n) followed by integers from 0 to A037834(n+1) and so on.
+20
8
0, 0, 1, 0, 0, 1, 0, 1, 2, 0, 1, 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 0, 1, 0, 1, 2, 0, 1, 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 0, 1, 2, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 0, 1, 0, 1, 2, 0, 1, 0, 0, 1, 0, 1, 2, 0, 1, 2, 3
COMMENTS
Equivalently, integers from 0 to A005811(n)-1 followed by integers from 0 to A005811(n+1)-1 and so on.
MATHEMATICA
Table[Range[0, #] &@ Total@ Flatten@ Map[Abs@ Differences@ # &,
Partition[IntegerDigits[n, 2], 2, 1]], {n, 34}] // Flatten (* Michael De Vlieger, May 09 2017 *)
Number of runs in binary expansion of n (n>0); number of 1's in Gray code for n.
(Formerly M0110)
+10
219
0, 1, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 3, 2, 1, 2, 3, 4, 3, 4, 5, 4, 3, 2, 3, 4, 3, 2, 3, 2, 1, 2, 3, 4, 3, 4, 5, 4, 3, 4, 5, 6, 5, 4, 5, 4, 3, 2, 3, 4, 3, 4, 5, 4, 3, 2, 3, 4, 3, 2, 3, 2, 1, 2, 3, 4, 3, 4, 5, 4, 3, 4, 5, 6, 5, 4, 5, 4, 3, 4, 5, 6, 5, 6, 7, 6, 5, 4, 5, 6, 5, 4, 5
COMMENTS
Starting with a(1) = 0 mirror all initial 2^k segments and increase by one.
a(n) gives the net rotation (measured in right angles) after taking n steps along a dragon curve. - Christopher Hendrie (hendrie(AT)acm.org), Sep 11 2002
This sequence generates A082410: (0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, ...) and A014577; identical to the latter except starting 1, 1, 0, ...; by writing a "1" if a(n+1) > a(n); if not, write "0". E.g., A014577(2) = 0, since a(3) < a(2), or 1 < 2. - Gary W. Adamson, Sep 20 2003
Starting with 1 = partial sums of A034947: (1, 1, -1, 1, 1, -1, -1, 1, 1, 1, ...). - Gary W. Adamson, Jul 23 2008
The composer Per Nørgård's name is also written in the OEIS as Per Noergaard.
Can be used as a binomial transform operator: Let a(n) = the n-th term in any S(n); then extract 2^k strings, adding the terms. This results in the binomial transform of S(n). Say S(n) = 1, 3, 5, ...; then we obtain the strings: (1), (3, 1), (3, 5, 3, 1), (3, 5, 7, 5, 3, 5, 3, 1), ...; = the binomial transform of (1, 3, 5, ...) = (1, 4, 12, 32, 80, ...). Example: the 8-bit string has a sum of 32 with a distribution of (1, 3, 3, 1) or one 1, three 3's, three 5's, and one 7; as expected. - Gary W. Adamson, Jun 21 2012
Considers all positive odd numbers as nodes of a graph. Two nodes are connected if and only if the sum of the two corresponding odd numbers is a power of 2. Then a(n) is the distance between 2n + 1 and 1. - Jianing Song, Apr 20 2019
REFERENCES
N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
LINKS
Chandler Davis and Donald E. Knuth, Number Representations and Dragon Curves -- I and II, Journal of Recreational Mathematics, volume 3, number 2, April 1970, pages 66-81, and number 3, July 1970, pages 133-149. Reprinted with addendum in Donald E. Knuth, Selected Papers on Fun and Games, 2010, pages 571-614. Equation 3.2 g(n) = a(n-1).
FORMULA
a(2^k + i) = a(2^k - i + 1) + 1 for k >= 0 and 0 < i <= 2^k. - Reinhard Zumkeller, Aug 14 2001
a(2n+1) = 2a(n) - a(2n) + 1, a(4n) = a(2n), a(4n+2) = 1 + a(2n+1).
a(j+1) = a(j) + (-1)^ A014707(j). - Christopher Hendrie (hendrie(AT)acm.org), Sep 11 2002
G.f.: (1/(1-x)) * Sum_{k>=0} x^2^k/(1+x^2^(k+1)). - Ralf Stephan, May 02 2003
Delete the 0, make subsets of 2^n terms; and reverse the terms in each subset to generate A088696. - Gary W. Adamson, Oct 19 2003
a(0) = 0, a(2n) = a(n) + [n odd], a(2n+1) = a(n) + [n even]. - Ralf Stephan, Oct 20 2003
a(0) = 0 then a(n) = a(floor(n/2)) + (a(floor(n/2)) + n) mod 2. - Benoit Cloitre, Jan 20 2014
EXAMPLE
Considered as a triangle with 2^k terms per row, the first few rows are:
1
2, 1
2, 3, 2, 1
2, 3, 4, 3, 2, 3, 2, 1
...
The n-th row becomes right half of next row; left half is mirrored terms of n-th row increased by one. - Gary W. Adamson, Jun 20 2012
MAPLE
local i, b, ans;
if n = 0 then
return 0 ;
end if;
ans := 1;
b := convert(n, base, 2);
for i from nops(b)-1 to 1 by -1 do
if b[ i+1 ]<>b[ i ] then
ans := ans+1
fi
od;
return ans ;
end proc:
# second Maple program:
a:= n-> add(i, i=Bits[Split](Bits[Xor](n, iquo(n, 2)))):
MATHEMATICA
Table[ Length[ Length/@Split[ IntegerDigits[ n, 2 ] ] ], {n, 1, 255} ]
a[n_] := DigitCount[BitXor[n, Floor[n/2]]]; Array[a, 100, 0] (* Amiram Eldar, Jul 11 2024 *)
PROG
(PARI) a(n)=sum(k=1, n, (-1)^((k/2^valuation(k, 2)-1)/2))
(PARI) a(n)=if(n<1, 0, a(n\2)+(a(n\2)+n)%2) \\ Benoit Cloitre, Jan 20 2014
(Haskell)
import Data.List (group)
a005811 0 = 0
a005811 n = length $ group $ a030308_row n
a005811_list = 0 : f [1] where
f (x:xs) = x : f (xs ++ [x + x `mod` 2, x + 1 - x `mod` 2])
(Python)
def a(n): return bin(n^(n>>1))[2:].count("1") # Indranil Ghosh, Apr 29 2017
CROSSREFS
Cf. A056539, A014707, A014577, A082410, A030308, A090079, A044813, A165413, A226227, A226228, A226229.
Total variation of base-10 digits of n; see Comments.
+10
91
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 8, 7, 6, 5, 4, 3, 2
COMMENTS
Suppose that a number n has base-b digits b(m), b(m-1), ..., b(0). The base-b down-variation of n is the sum DV(n,b) of all d(i)-d(i-1) for which d(i) > d(i-1); the base-b up-variation of n is the sum UV(n,b) of all d(k-1)-d(k) for which d(k) < d(k-1). The total base-b variation of n is the sum TV(n,b) = DV(n,b) + UV(n,b). Guide to related sequences and partitions of the natural numbers:
***
Base b {DV(n,b)} {UV(n,b)} {TV(n,b)}
For each b, let u = {n : UV(n,b) < DV(n,b)}, e = {n : UV(n,b) = DV(n,b)}, and d = {n : UV(n,b) > DV(n,b)}. The sets u,e,d partition the natural numbers. A guide to the matching sequences for u, e, d follows:
***
Base b Sequence u Sequence e Sequence d
EXAMPLE
13684632 has DV = 8-4 + 6-3 + 3-2 = 8 and has UV = 3-1 + 6-3 + 8-6 + 6-4 = 9, so that a(13684632) = DV + UV = 17.
MAPLE
f:= proc(n) local L, i; L:= convert(n, base, 10);
add(abs(L[i+1]-L[i]), i=1..nops(L)-1) end proc:
# alternative
MATHEMATICA
b = 10; z = 120; t = Table[Total@Flatten@Map[Abs@Differences@# &, Partition[ IntegerDigits[n, b], 2, 1]], {n, z}] (* after Michael De Vlieger, e.g. A037834 *)
PROG
(Python)
s = str(n)
return sum(abs(int(s[i])-int(s[i+1])) for i in range(len(s)-1)) # Chai Wah Wu, May 31 2022
Filter-sequence related to base-2 run-length encoding: a(n) = A046523( A243353(n)).
+10
17
1, 2, 4, 2, 4, 8, 6, 2, 4, 12, 16, 8, 6, 12, 6, 2, 4, 12, 36, 12, 16, 32, 24, 8, 6, 30, 24, 12, 6, 12, 6, 2, 4, 12, 36, 12, 36, 72, 60, 12, 16, 48, 64, 32, 24, 72, 24, 8, 6, 30, 60, 30, 24, 48, 60, 12, 6, 30, 24, 12, 6, 12, 6, 2, 4, 12, 36, 12, 36, 72, 60, 12, 36, 180, 144, 72, 60, 180, 60, 12, 16, 48, 144, 48, 64, 128, 96, 32, 24, 120, 216, 72, 24, 72
MATHEMATICA
f[n_, i_, x_] := Which[n == 0, x, EvenQ@ n, f[n/2, i + 1, x], True, f[(n - 1)/2, i, x Prime@ i]]; g[n_] := If[n == 1, 1, Times @@ MapIndexed[ Prime[First@ #2]^#1 &, Sort[FactorInteger[n][[All, -1]], Greater]]];
Table[g@ f[BitXor[n, Floor[n/2]], 1, 1], {n, 0, 93}] (* Michael De Vlieger, May 09 2017 *)
PROG
(Python)
from sympy import prime, factorint
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))
def a005940(n): return b(n - 1)
def P(n):
f = factorint(n)
return sorted([f[i] for i in f])
def a046523(n):
x=1
while True:
if P(n) == P(x): return x
else: x+=1
def a003188(n): return n^int(n/2)
def a243353(n): return a005940(1 + a003188(n))
CROSSREFS
Sequences that (seem to) partition N into same or coarser equivalence classes are at least these: A005811, A136004, A033264, A037800, A069010, A087116, A090079 and many others like A105500, A106826, A166242, A246960, A277561, A037834, A225081 although these have not been fully checked yet.
a(1)=0. Thereafter, the sequence is constructed using the rule: for any k >= 0, if a(1), a(2), ..., a(2^k+1) are known, the next 2^k terms are given as follows: a(2^k+1+i) = 1 - a(2^k+1-i) for 1 <= i <= 2^k.
+10
11
0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1
COMMENTS
Complement of characteristic function of A060833.
Suppose you have a deck of cards face down with 2^n cards such that the color pattern corresponds to this sequence: 0 for one color, 1 for the other. Then you proceed in the following manner: transfer to top card to the bottom of the deck, deal the next card, then repeat. The dealt cards will have alternating colors.
Even terms of this sequence alternate: 1, 0, 1, 0 and so on.
Removing even-indexed terms doesn't change the sequence. (End)
FORMULA
For n >= 2, Sum_{k=1..n} a(k) = (n + A037834(n-1))/2.
a(1) = 0, a(4*n+2) = 1, a(4*n+4) = 0, a(2*n+1) = a(n+1) for n >= 0. - A.H.M. Smeets, Jul 27 2018
EXAMPLE
First 3 terms are 0,1,1; therefore, a(4) = a(3+1) = 1 - a(3-1) = 1 - a(2) = 0, a(5) = a(3+2) = 1 - a(3-2) = 1 - a(1) = 1 and the sequence begins 0, 1, 1, 0, 1, ...
PROG
(Python)
if n == 1:
return 0
s = bin(n-1)[2:]
m = len(s)
i = s[::-1].find('1')
return 1-int(s[m-i-2]) if m-i-2 >= 0 else 1 # Chai Wah Wu, Apr 08 2021
0, 1, 3, 4, 6, 9, 11, 12, 14, 17, 21, 24, 26, 29, 31, 32, 34, 37, 41, 44, 48, 53, 57, 60, 62, 65, 69, 72, 74, 77, 79, 80, 82, 85, 89, 92, 96, 101, 105, 108, 112, 117, 123, 128, 132, 137, 141, 144, 146, 149, 153, 156, 160, 165, 169, 172, 174, 177, 181, 184, 186, 189
COMMENTS
Partial sums of number of runs in binary expansion of n (n>0). Partial sums of number of 1's in Gray code for n. The subsequence of squares in this partial sum begins 0, 1, 4, 9, 144, 169, 256, 289, 324 (since we also have 32 and 128 I wonder about why so many powers). The subsequence of primes in this partial sum begins: 3, 11, 17, 29, 31, 37, 41, 53, 79, 89, 101, 137, 149, 181, 191, 197, 229, 271.
FORMULA
a(2n) = 2*a(n) + n - 2*(ceiling( A005811(n)/2) - (n mod 2)), a(2n+1) = 2*a(n) + n + 1. - Ralf Stephan, Aug 11 2013
EXAMPLE
1 has 1 run in its binary representation "1".
2 has 2 runs in its binary representation "10".
3 has 1 run in its binary representation "11".
4 has 2 runs in its binary representation "100".
5 has 3 runs in its binary representation "101".
Thus a(1) = 1, a(2) = 1+2 = 3, a(3) = 1+2+1 = 4, a(4) = 1+2+1+2 = 6, a(5) = 1+2+1+2+3 = 9.
MATHEMATICA
Accumulate[Join[{0}, Table[Length[Split[IntegerDigits[n, 2]]], {n, 110}]]] (* Harvey P. Dale, Jul 29 2013 *)
PROG
(PARI) a(n) = my(v=binary(n+1), d=0, e=4); for(i=1, #v, if(v[i], v[i]=#v-i+d; d+=e; e=0, e=4)); fromdigits(v, 2)>>1; \\ Kevin Ryde, Aug 27 2021
Total variation of base-11 digits of n; see Comments.
+10
4
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2
COMMENTS
Suppose that a number n has base-b digits b(m), b(m-1), ..., b(0). The base-b down-variation of n is the sum DV(n,b) of all d(i)-d(i-1) for which d(i) > d(i-1); the base-b up-variation of n is the sum UV(n,b) of all d(k-1)-d(k) for which d(k) < d(k-1). The total base-b variation of n is the sum TV(n,b) = DV(n,b) + UV(n,b). See A297330 for a guide to related sequences and partitions of the natural numbers:
EXAMPLE
2^20 in base 11: 6, 5, 6, 8, 10, 1; here, DV = 12 and UV = 5, so that a(2^20) = 17.
MATHEMATICA
b = 11; z = 120; t = Table[Total@Flatten@Map[Abs@Differences@# &, Partition[IntegerDigits[n, b], 2, 1]], {n, z}] (* cf. Michael De Vlieger, e.g. A037834 *)
Total variation of base-13 digits of n; see Comments.
+10
4
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 0, 1
COMMENTS
Suppose that a number n has base-b digits b(m), b(m-1), ..., b(0). The base-b down-variation of n is the sum DV(n,b) of all d(i)-d(i-1) for which d(i) > d(i-1); the base-b up-variation of n is the sum UV(n,b) of all d(k-1)-d(k) for which d(k) < d(k-1). The total base-b variation of n is the sum TV(n,b) = DV(n,b) + UV(n,b). See A297330 for a guide to related sequences and partitions of the natural numbers:
EXAMPLE
2^20 in base 13: 2, 10, 9, 3, 7, 9; here, DV = 12 and UV = 9, so that a(2^20) = 21.
MATHEMATICA
b = 13; z = 120; t = Table[Total@Flatten@Map[Abs@Differences@# &, Partition[IntegerDigits[n, b], 2, 1]], {n, z}] (* cf. Michael De Vlieger, e.g. A037834 *)
Total variation of base-14 digits of n; see Comments.
+10
4
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 6
COMMENTS
Suppose that a number n has base-b digits b(m), b(m-1), ..., b(0). The base-b down-variation of n is the sum DV(n,b) of all d(i)-d(i-1) for which d(i) > d(i-1); the base-b up-variation of n is the sum UV(n,b) of all d(k-1)-d(k) for which d(k) < d(k-1). The total base-b variation of n is the sum TV(n,b) = DV(n,b) + UV(n,b). See A297330 for a guide to related sequences and partitions of the natural numbers:
EXAMPLE
2^20 in base 14: 1, 13, 4, 1, 12, 4; here, DV = 20 and UV = 23, so that a(2^20) = 43.
MATHEMATICA
b = 14; z = 120; t = Table[Total@Flatten@Map[Abs@Differences@# &, Partition[IntegerDigits[n, b], 2, 1]], {n, z}] (* cf. Michael De Vlieger, e.g. A037834 *)
Total variation of base-15 digits of n; see Comments.
+10
4
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 4, 3, 2, 1, 0, 1, 2, 3
COMMENTS
Suppose that a number n has base-b digits b(m), b(m-1), ..., b(0). The base-b down-variation of n is the sum DV(n,b) of all d(i)-d(i-1) for which d(i) > d(i-1); the base-b up-variation of n is the sum UV(n,b) of all d(k-1)-d(k) for which d(k) < d(k-1). The total base-b variation of n is the sum TV(n,b) = DV(n,b) + UV(n,b). See A297330 for a guide to related sequences and partitions of the natural numbers:
EXAMPLE
2^20 in base 15: 1, 5, 10, 10, 5, 1; here, DV = 9 and UV = 9, so that a(2^20) = 18.
MATHEMATICA
b = 15; z = 120; t = Table[Total@Flatten@Map[Abs@Differences@# &, Partition[IntegerDigits[n, b], 2, 1]], {n, z}] (* cf. Michael De Vlieger, e.g. A037834 *)
Search completed in 0.027 seconds
|