A343453 The number of 3's minus the number of 2's among the first n terms of A342101.
0, -1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 2, 2, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 2, 2, 1, 1, 2, 2, 1, 2, 2, 2, 1, 1, 1, 0, 1, 1, 2, 2, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 2, 2, 1, 1, 2, 2, 1, 2, 2, 2, 1, 1, 2, 2, 1, 2, 2, 3
Offset: 1
Keywords
Examples
A342101 = [1, 2, 3, 1, 3, ...]. By the fifth term of A342101 we see 2 terms with value 3, and a single term with value 2, so a(5) = 2 - 1 = 1.
Links
- Kevin Ryde, PARI/GP Code and Notes.
Crossrefs
Cf. A342101.
Programs
-
Kotlin
fun a(iter: Int): List
= runningSum(twosVersusThrees(iter)) fun runningSum(a: List ) = a.drop(1).fold(listOf(a[0])) { acc, cur -> acc + (acc.last() + cur) } fun twosVersusThrees(iter: Int): List = removeMiddle(listOf(0,-1,1), iter) fun removeMiddle(initial: List , iter: Int): List { if (iter < 2) return initial val prev = removeMiddle(initial, iter-1) return prev + prev.subList(0, (prev.size - 1) / 2) + prev.subList((prev.size + 1) /2, prev.size) } -
Mathematica
Block[{a = {}, s = Nest[Join[#, Drop[#, {(Length[#] + 1)/2}]] &, Range[3], 6], c}, Array[Set[c[#], 0] &, 3]; Do[c[ s[[i]] ]++; AppendTo[a, c[3] - c[2]], {i, Min[Length@ s, 104]}]; a] (* Michael De Vlieger, May 01 2021 *)
-
PARI
\\ See links.
Comments