Yes, it is possible to find modulo (p) and sequence value (y) for given number x, but it requires using floating-arithmetics logarithm.
pow = Floor(Log2(x+1))
p = 1 << pow
y = 1 + (x + 1) % p
For initial period s (3 in your second example)
pow = Floor(Log2((x + s - 1) / s))
p = s * (1 << pow)
y = 1 + (x + s - 1) % p
check:
x=9 pow = 1 p = 6 y = 6
x=10 pow = 2 p = 12 y = 1
x=21 pow = 2 p = 12 y = 12
7
solved How to generate increasing periodic sequences without using “if condition/loop/states”? [closed]