Questions about n < 2^k

I see you used k = ceil(n log2(3))

No, I only assumed an integer cycle, see this discussion