Rubik's cube function

The answer for a $4 \times 4 \times 4$, $5\times 5\times 5$, and so on cube will continue to be $112$.

Here's why. Imagine that you take an $n \times n \times n$ cube and, on each face, glue the pieces in the middle $(n-2) \times (n-2)$ square together, so they cannot be separated. Similarly, glue the middle $n-2$ pieces along each edge together. What you have is no longer an $n \times n \times n$ cube, but a $3 \times 3 \times 3$ cube in which some of the pieces are much larger in size. But it still operates exactly like a $3 \times 3 \times 3$ cube and affords exactly the same twists.

Your repeated RULU' move is acting on the $n \times n \times n$ cube in a way that gluing the pieces as above doesn't forbid. So whatever happens on the $n \times n \times n$ cube for $n>3$ is exactly the same as what happens for the $3 \times 3 \times 3$ cube.

The only reason that the $2 \times 2 \times 2$ cube is an exception is that here, there are no "edge" pieces at all. So if a sequence of moves in the $3 \times 3 \times 3$ cube scrambles (or flips) the edges but leaves the corners fixed, then on the $2 \times 2 \times 2$ cube, it does nothing, and this exactly describes what $28$ iterations of RULU' do.


Have you tried it on a $4\times4\times4$ cube? If not there are online rubiks cubes you can play around with.

But to answer your question my guess is that for any cube size $3$ and up you'll solve it again in $112$ moves. That is because R U L' U' doesn't touch any of the "inner" edges so that means larger cubes will all behave like a $3\times3\times3$ cube in this case.


What if the middle squares in a $4\times4\times4$ are scrambled?

Here's a couple more resources to help you with your mathematical journey. A full analysis of the Rubiks Cube, based on a 2-week long summer Research Experience for Undergraduates, can be found here. In particular, you found what's called a group generator. The number of steps is the order of the group element (distinct from the order of the group itself).