Define $f$ on the positive integers by $f(n) = k^2 + k + 1$, where $n=2^k(2l+1)$ for some $k,l$ nonnegative integers. 
Find the smallest $n$ such that $f(1) + f(2) + ... + f(n) \geq 123456$.
To solve the problem, we need to find the smallest \( n \) such that the sum \( f(1) + f(2) + \cdots + f(n) \geq 123456 \). The function \( f(n) \) is defined as \( f(n) = k^2 + k + 1 \) where \( n = 2^k(2l+1) \) for some nonnegative integers \( k \) and \( l \).

1. **Understanding the function \( f(n) \)**:
   Given \( n = 2^k(2l+1) \), we can see that \( k \) is the exponent of the highest power of 2 dividing \( n \). For each \( k \), \( f(n) = k^2 + k + 1 \).

2. **Summing the function \( f(n) \)**:
   We need to sum \( f(n) \) from \( n = 1 \) to \( n \). The sum can be written as:
   \[
   S(n) = \sum_{i=1}^n f(i)
   \]
   We need to find the smallest \( n \) such that \( S(n) \geq 123456 \).

3. **Using the given formula**:
   The given formula for the sum is:
   \[
   S(n) = \sum_{k=0}^{\infty} (k^2 + k + 1) \left\lfloor \frac{n + 2^k}{2^{k+1}} \right\rfloor
   \]
   This formula accounts for the contributions of each \( k \) to the sum.

4. **Simplifying the sum for powers of 2**:
   For \( n = 2^l \), the sum simplifies to:
   \[
   S(2^l) = 1 + 2^{l-1} \left(1 + \frac{3}{2} + \cdots + \frac{l(l-1) + 1}{2^{l-1}}\right) = 7 - 2(l^2 + 2l + 3)2^{-l}
   \]
   This formula gives the sum for \( n \) being a power of 2.

5. **Generalizing the sum for any \( n \)**:
   For \( n = 2^{l_1} + 2^{l_2} + \cdots \) with \( l_1 > l_2 > \cdots \), we have:
   \[
   S(n) = S(2^{l_1}) + S(2^{l_2}) + \cdots
   \]

6. **Finding the smallest \( n \)**:
   We need to find the smallest \( n \) such that \( S(n) \geq 123456 \). We can start by calculating \( S(n) \) for increasing values of \( n \) until the sum exceeds 123456.

   Let's calculate \( S(n) \) for some values of \( n \):
   - For \( n = 1 \): \( f(1) = 1^2 + 1 + 1 = 3 \)
   - For \( n = 2 \): \( f(2) = 1^2 + 1 + 1 = 3 \)
   - For \( n = 3 \): \( f(3) = 1^2 + 1 + 1 = 3 \)
   - For \( n = 4 \): \( f(4) = 2^2 + 2 + 1 = 7 \)
   - For \( n = 5 \): \( f(5) = 2^2 + 2 + 1 = 7 \)
   - For \( n = 6 \): \( f(6) = 2^2 + 2 + 1 = 7 \)
   - For \( n = 7 \): \( f(7) = 2^2 + 2 + 1 = 7 \)
   - For \( n = 8 \): \( f(8) = 3^2 + 3 + 1 = 13 \)

   Summing these values:
   \[
   S(8) = 3 + 3 + 3 + 7 + 7 + 7 + 7 + 13 = 50
   \]

   We continue this process until the sum \( S(n) \) exceeds 123456. This requires a more systematic approach or a programmatic solution to find the exact smallest \( n \).

The final answer is \( \boxed{ n } \) such that \( S(n) \geq 123456 \).