Max Length Sequence

Let \( M \in \mathbb{ R } \) then largest value of \( n \) such that there is a finite sequence \( \left( a _ 1, \ldots a _ n \right) \in \mathbb{ R } ^ n \) where each term is bounded below by \( \epsilon \in \mathbb{ R } ^ { \gt 0 } \) and that
\[
\sum _ { i = 1 } ^ n a _ i = M
\]
is given by \( n = \lfloor \frac{M}{\epsilon } \rfloor \)

First note that it's impossible for \( n \gt \frac{M}{\epsilon } \), since if it were true we would know that: \[ \sum _ { i = 0 } ^ n a _ i \ge n \epsilon \gt \frac{M}{\epsilon } \epsilon = M \] but we require this sum to be equal to \( M \), therefore we know that \( n \le \frac{M}{\epsilon } \). So we have an upper bound on the value of \( n \)

Suppose that \( \epsilon \mid M \), therefore \( \frac{M}{\epsilon } \in \mathbb{ Z } \), and thus by taking \( n = \frac{M}{\epsilon } \) then clearly \( n \) is at a maximum as needed, and by taking \( a _ i = \epsilon \) we have \[ \sum _ { i = 1 } ^ n a _ i = n \epsilon = M \] Also note that \( \left\lfloor \frac{M}{\epsilon } \right\rfloor = \frac{M}{\epsilon } \) in this case.

Otherwise \( \epsilon \nmid M \), therefore \( \frac{M}{\epsilon } \in \mathbb{ R } \setminus \mathbb{ Z } \), therefore we can certainly not pick \( n = \frac{M}{\epsilon } \), and as stated earlier we cannot have \( n \) exceed this value, so the next largest value would the largest integer less than or equal to \( \frac{M}{\epsilon } \) which is defined as \( \lfloor \frac{M}{\epsilon } \rfloor \)

Recall that by the quotient remainder theorem there exists some \( q, r \in \mathbb{ Z } \) such that \( q \cdot \epsilon + r = M \), and that specifically we have that \( q = \left\lfloor \frac{M}{\epsilon } \right\rfloor \) and \( r = M - \left\lfloor \frac{M}{\epsilon } \right\rfloor \epsilon \) which yields the equation

\[ \left\lfloor \frac{M}{\epsilon } \right\rfloor \cdot \epsilon + \left( M - \left\lfloor \frac{M}{\epsilon } \right\rfloor \epsilon \right) = \left( \left\lfloor \frac{M}{\epsilon } \right\rfloor - 1 \right) \cdot \epsilon + \left( M - \left\lfloor \frac{M}{\epsilon} \right\rfloor \epsilon + \epsilon \right) \] And note that since \( r \ge 0 \), well that is \( M - \left\lfloor \frac{M}{\epsilon } \right\rfloor \ge 0 \), we know that \[ M - \left\lfloor \frac{M}{\epsilon } \right\rfloor \epsilon + \epsilon \gt \epsilon \] and thus the sequence given by \( a _ i = \epsilon \) for \( i \in \left[ 1 \ldots \left( \left\lfloor \frac{M}{\epsilon } \right\rfloor - 1 \right) \right] \) and \[ a _ { \left\lfloor \frac{M}{\epsilon } \right\rfloor } = \left( M - \left\lfloor \frac{M}{\epsilon } \right\rfloor \epsilon + \epsilon \right) \] is clearly bounded below by \( \epsilon \), and has sum equal to \( M \), and has \( \left\lfloor \frac{M}{\epsilon } \right\rfloor \) terms, so the largest value of \( n \) is preciely that.One way to understand what's going on here is to look at the following example where we have \( M = 38 \) and \( \epsilon = 5 \), in this case since \( \epsilon \nmid M \), then we know that we'd construct the sequence \( a _ 1 = a _ 2 = a _ 3 = a _ 4 = a _ 5 = a _ 6 = 5 \) and then we have that \( a _ 7 = 3 + 5 = 8 \), so here it maintains the smallest value until it would exceed it, and then combines the extra overflow into the previous term in the sequence which shortens the sequence and allows it to equal \( 38 \)