Primes & Modulo
What I have observed is that for the following expression, choose a positive integer $m$, and if it is prime then for positive integers $n=1,2,3,\ldots$ the results will be $0,1,1,1,\ldots$ such that the sequence is made of $0$'s and $1$'s which repeat in a way that there is a $0$, then $(m-1)$ $\times$ $1$'s and then again $0$ and $1$'s...
For $m=2$ we have for $n=1,2,3,\ldots$ following results: $0,1,0,1,0,1,0,1,0,1,\ldots$
For $m=3$ we have: $0,1,1,0,1,1,0,1,1,0,1,1,\ldots$
For $m=5$ we have: $0,1,1,1,1,0,1,1,1,1,0,1,\ldots$
And for non-prime numbers we get a specific mix of repeating numbers that repeat every $m$ numbers, for example:
$m=6$, We get a repeating sets of $0,3,4,3,0,1$
$m=8$, We have: $0,7,0,5,0,3,0,1$
I have accidentally stumbled upon this property, in fact I don't know if its 100% true since I've checked a handful of numbers only.
Is there an explanation for this property, why does it work for prime numbers like that?
Is there any significance or any kind of a pattern in numbers that appear for non-prime numbers?
Is there any significance to this expression, and does this expression or something similar appear somewhere in mathematics? In a specific field, equations, theorems... somewhere in the mathematical history... or simply mentioned somewhere else before?