Can you help me with my code

Here output is recurring like 1 1 1 1 2 2 2 3 3 3 3