A330261 Start with an empty stack S; for n = 1, 2, 3, ..., interpret the binary representation of n from left to right as follows: in case of bit 1, push the number 1 on top of S, in case of bit 0, replace the two numbers on top of S, say u on top of v, with u-v; a(n) gives the number on top of S after processing n.
1, 0, 1, -1, 1, 0, 1, -2, 1, 1, 1, -1, 1, 0, 1, -3, 1, 4, 1, 0, 1, 0, 1, -2, 1, 1, 1, -1, 1, 0, 1, -4, 1, 5, 1, 7, 1, 0, 1, -1, 1, 0, 1, 0, 1, 0, 1, -3, 1, 2, 1, 0, 1, 0, 1, -2, 1, 1, 1, -1, 1, 0, 1, -5, 1, 5, 1, -4, 1, 0, 1, 3, 1, -3, 1, 1, 1, 0, 1, -2, 1, -2
Offset: 1
Examples
The first terms, alongside the binary representation of n and the evolution of stack S, are: n a(n) bin(n) S -- ---- ------ ------------------------------------------------------------ 1 1 1 () -> (1) 2 0 10 (1) -> (1,1) -> (0) 3 1 11 (0) -> (0,1) -> (0,1,1) 4 -1 100 (0,1,1) -> (0,1,1,1) -> (0,1,0) -> (0,-1) 5 1 101 (0,-1) -> (0,-1,1) -> (0,2) -> (0,2,1) 6 0 110 (0,2,1) -> (0,2,1,1) -> (0,2,1,1,1) -> (0,2,1,0) 7 1 111 (0,2,1,0) -> (0,2,1,0,1) -> (0,2,1,0,1,1) -> (0,2,1,0,1,1,1)
Links
- Rémy Sigrist, Table of n, a(n) for n = 1..8192
- Rémy Sigrist, Scatterplot of the first 2^20 terms
- Rémy Sigrist, PARI program for A330261
Programs
-
PARI
See Links section.
Formula
a(2*k-1) = 1 for any k > 0.
Comments