login
A383909
In the base 4 expansion of n, map: 0 -> 20, 1 -> 21, 2 -> 30, 3 -> 31.
1
8, 9, 12, 13, 152, 153, 156, 157, 200, 201, 204, 205, 216, 217, 220, 221, 2440, 2441, 2444, 2445, 2456, 2457, 2460, 2461, 2504, 2505, 2508, 2509, 2520, 2521, 2524, 2525, 3208, 3209, 3212, 3213, 3224, 3225, 3228, 3229, 3272, 3273, 3276, 3277, 3288, 3289, 3292, 3293
OFFSET
0,1
COMMENTS
This is the fixed point of the morphism or substitution rules involved in the regular paperfolding sequence and these rules are: map bits: 00 -> 1000, 01 -> 1001, 10 -> 1100, 11 -> 1101.
This sequence contains no fixed points and all terms have an even bit size.
FORMULA
a(n+1) = a(n)+1 for n even.
a(2^k) = ((4^k)(95 + 48(-1)^k) - 8)/15.
EXAMPLE
For n = 216 a(216) = 55752 because:
216 = 3120_4 and
pos | b4 | enc
-----+----+------------
0 | 3 | 31
1 | 1 | 31 21
2 | 2 | 31 21 30
3 | 0 | 31 21 30 20
and 31213020_4 is 55752.
MAPLE
a:= proc(n) option remember; [8, 9, 12, 13]
[irem(n, 4, 'q')+1]+`if`(n<4, 0, 16*a(q))
end:
seq(a(n), n=0..47); # Alois P. Heinz, May 14 2025
MATHEMATICA
A383909[n_] := FromDigits[StringReplace[IntegerString[n, 4], {"0"->"20", "1"->"21", "2"->"30", "3"->"31"}], 4];
Array[A383909, 50, 0] (* Paolo Xausa, May 22 2025 *)
PROG
(Python)
def tobase4(n):
if n == 0: return [0]
d = []
while n > 0:
d.append(n & 3)
n >>= 2
return d[::-1]
def a(n):
B4 = ['20', '21', '30', '31']
return int(''.join(B4[b] for b in tobase4(n)), 4)
print([a(n) for n in range(1, 48)])
(Python)
def A383909(n):
s = ('0' if n.bit_length()&1 else '')+bin(n)[2:] if n else '00'
return int(''.join(('1000', '1001', '1100', '1101')[int(s[i:i+2], 2)] for i in range(0, len(s), 2)), 2) # Chai Wah Wu, May 22 2025
CROSSREFS
Cf. A014577.
Sequence in context: A199635 A131864 A347392 * A179443 A264828 A394710
KEYWORD
nonn,base,easy
AUTHOR
Darío Clavijo, May 14 2025
STATUS
approved