login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A334955 Number of 1's in n-th string when A000002 is expressed as 1,2,2,11,21,221,22112,11221211,21221121121,2212211212212112, 0
0, 2, 1, 1, 2, 5, 6, 7, 12, 19, 29, 43, 62, 95, 148, 216, 322, 482, 727, 1083, 1627, 2457, 3660, 5518, 8250, 12403, 18594, 27914, 41863, 62781, 94158, 141205, 211797, 317782, 476743, 714948, 1072526, 1608732, 2413223, 5428986 (list; graph; refs; listen; history; text; internal format)
OFFSET
3,2
COMMENTS
Representing A000002 as a tree. Each branch of this tree is a string. Starting from n=3, each 1 in n-th string generates either 1 or 2 in (n+1)-th string and each 2 in n-th string generates either 11 or 22 in (n+1)-st string based on the previously generated term of either 2 or 1. Hence number of terms in (n+1)-st string is sum of all terms in n-th string.
LINKS
PROG
(Python)
MAX_NUM = 10000 # Number of terms in Kolakoski Sequence
K = [1, 2, 2]
previous = 2
# Generate Kolakoski Sequence
for index1 in range(2, MAX_NUM):
generator = K[index1]
if (generator == 1 and previous == 1):
K.append(2)
previous = 2
elif(generator == 2 and previous == 1):
K.append(2)
K.append(2)
previous = 2
elif(generator == 1 and previous == 2):
K.append(1)
previous = 1
elif(generator == 2 and previous == 2):
K.append(1)
K.append(1)
previous = 1
branch_sum = 1
index2 = 2
cntr1 = 1
while(index2 < MAX_NUM):
ones_cntr = 0
# This for loop extracts strings from Kolakoski Sequence
start_index = index2
end_index = index2 + branch_sum
branch_sum = 0
for index3 in range(start_index , end_index):
branch_sum = branch_sum + K[index3]
ones_cntr = ones_cntr + (K[index3]%2)
index2 = end_index
print(str(cntr1)+" "+str(ones_cntr)+"\n")
cntr1 = cntr1 + 1
CROSSREFS
Cf. A000002.
Sequence in context: A172483 A216396 A273488 * A117848 A025242 A356696
KEYWORD
nonn
AUTHOR
Rakesh Khanna A, May 24 2020
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 26 13:14 EDT 2024. Contains 374635 sequences. (Running on oeis4.)