How to find the size of gaps between entries in an array so that the first and last element of the array is filled and the gaps are all of equal size? I have an array a of n entries. I need to place a token on the first and last position of that array, so a[0] = 1 and a[n-1] = 1.
I now want to place additional tokens into that array with a distance inbetween each index i where a[i] = 1 that is greater than 2 (so placing a token on every index is invalid as well as alternating using and not using an entry is invalid). Phrazed differently: I want that sum(a) &lt; n/2 . The gap inbetween each token should be the same, so say with an array of size 16,
a[0] = 1, a[3] = 1, a[6] = 1, a[9] = 1, a[12] = 1, a[15] = 1
would be a solution with a gap size of 2 (distance of 3).
How do I find all gap sizes that are possible to fill said array with the given constraints?
Imagine a street inbetween two crossroads where a lamppost should be placed on each crossroad and then additional lampposts should be placed equidistant to each other and for some reason only natural number distances are allowed.
(The actual problem I want to solve is where to place Sea Lanterns in my Minecraft Project so do not disregard this problem as an assignment question I want a solution for.)
If I understand your problem correctly, the tokens (lanterns) can be placed every $x$ blocks (starting from $0$) if and only if $x&gt;2$ is a divisor of  $n-1$.
For example, if the array has $n=31$ elements the valid values of $x$ are $3,5,6,10,15,$ and $30$.