A289322
Number of 1s in the first 2^n entries of the Kolakoski sequence, A000002.
Original entry on oeis.org
1, 1, 2, 4, 8, 17, 32, 64, 129, 256, 513, 1024, 2051, 4093, 8192, 16381, 32746, 65523, 131082, 262168, 524262, 1048547, 2097100, 4194345, 8388733, 16777351, 33554669, 67109796, 134219275, 268437750, 536872179
Offset: 0
The first 32 entries of the Kolakoski sequence, A000002, are 12211212212211211221211212211211. From this we see that a(5)=17, since among the first 2^5 letters, 17 of them are 1s.
A195211
Number of 2s in the first 10^n entries of the generalized Kolakoski-(2,3) sequence A071820.
Original entry on oeis.org
1, 5, 51, 502, 4995, 49999, 499980, 4999995, 50000202, 499999731, 5000005565, 50000013114, 499999997503, 4999999971938, 49999999974390, 499999999976909, 4999999999414101, 50000000022964476, 500000000029433861, 4999999999986496894
Offset: 0
The first entries of the Kolakoski-(2,3) sequence, A071820, are 2233222333... From this we see that a(0)=1, since the first letter is 2, and a(1) = 5 since among the first 10 letters 5 of them are 2s.
a(13)-a(14) from
Ed Wynn, Jun 24 2014
A289324
Number of twos minus number of ones in the first 10^n entries of the Kolakoski sequence, A000002.
Original entry on oeis.org
-1, 0, 2, -4, 8, 56, 28, -92, -1350, -2446, 4658, -3174, -101402, -16318, -632474, -1954842, 10724544, 45041304, 111069790, 548593100, 1818298480
Offset: 0
The first 10 entries in the Kolakoski sequence, A000002, are 1221121221. There are 5 ones and 5 twos, so a(1) = 5 - 5 = 0.
The first 100=10^2 entries in the Kolakoski sequence A000002 include 49 ones and 51 twos, so a(2) = 51 - 49 = 2.
A342407
Number of 2's in the first 10^n entries of the Kolakoski sequence (A000002).
Original entry on oeis.org
0, 5, 51, 498, 5004, 50028, 500014, 4999954, 49999325, 499998777, 5000002329, 49999998413, 499999949299, 4999999991841, 49999999683763, 499999999022579, 5000000005362272, 50000000022520652, 500000000055534895, 5000000000274296550, 50000000000909149240
Offset: 0
The first 10 entries of the Kolakoski sequence (A000002) are 1221121221. From this we see that a(0) = 0, since the first term is not a 2, and a(1)=5 since among the first 10 terms, 5 of them are 2's.
-
package main
import (
"fmt"
"math"
)
func main() {
fmt.Println(a(5))
}
func a(n int) int {
k := int(math.Pow(10, float64(n))) // get the number of terms of the Kolakoski sequence (A000002) to generate
// seq stores the Kolakoski sequence
seq := make([]int, 0, k+1) // n+1 because instruction 2 could add one extra
var ind, i, toAppend int // ind represents which instruction to follow
seq = append(seq, 1, 2, 2) // initial terms
ind = 2 // follow third instruction next
i += 3 // three numbers already added
for i < k {
if seq[ind] == 1 { // add one number?
if seq[len(seq)-1] == 1 {
toAppend = 2
} else {
toAppend = 1
}
seq = append(seq, toAppend)
i++ // we added a number
ind++ // next instruction
} else { // add two numbers
if seq[len(seq)-1] == 1 {
toAppend = 2
} else {
toAppend = 1
}
seq = append(seq, toAppend, toAppend) // append two numbers
i += 2 // we added two numbers
ind++
}
}
seq = seq[:k] // trim to k values
// now count twos
var twos int
for _, curr := range seq {
if curr == 2 {
twos++
}
}
return twos
}
Showing 1-4 of 4 results.
Comments