A Peculiar Function I thought of a puzzle where a function outputs a concatenated number, depending on the input. If the input is 1, then the output is 1111...111111, where there are 2018 1's put together to form a number. The stipulation is that the greatest value in the function's domain is 2018 (to fit with the 2018 theme!). The question is, what values of inputs in the range 1-2018 inclusive, outputs a number divisible by 11? 
I started this question with considering the alternating sum rule of the divisibility test for 11. I found that 1-9 work, 11, 22, 33, 44, 55, 66, 77, 88, and 99 work, as well as other numbers with identical digits in their representation. However, I don't know what other numbers are successes, and what the exact number of successful values is. Is there any more ways to proceed? What other approaches are viable, and does anyone know of a slick or intuitive solution to this? Is there a generalization to this problem that can be considered to extend this problem/puzzle? Thank you in advance!
 A: Let the input be $k$, and let $l$ be the number of digits in $k$. We have that
$$f(k) = k\cdot (10\cdots010\cdots010\cdots\cdots\cdots010\cdots01)$$
where there are $2018$ ones and $l-1$ zeroes between each pair of ones. Since $11$ is prime, $11|f(k)$ iff $11|k$ or 
$$11|(10\cdots010\cdots010\cdots\cdots\cdots010\cdots01)$$
We can use the divisibility test for $11$s now. If $l$ is odd, the sum of the digits in even positions is $1009$, the same sum of digits in odd positions. Thus $11$ divides it. However, if $l$ is even, the sum of the digits in odd positions is $0$, while in even positions it is all $2018$. Since $11\nmid 2018$, this means that $11$ does not divide $f(k)$.
In summary, $11$ divides $f(k)$ iff $11|k$ or the number of digits in $k$ is odd. 
An interesting note is that in $2024$, $11$ will always divide $k$ concatenated $2024$ times. 
A: The alternating sum rule for divisibility by 11 means that if the number's digits can be divided into repeating blocks with an even number of digits, then divisibility by 11 requires either the number of blocks to be divisible by 11 or that the block itself is divisible by 11. Since 2018 isn't divisible by 11, we'll need the blocks to be divisible by 11. If $n$ has an even number of digits, then $n$ itself is the repeating block, and $11|f(n)$ if and only if $11|n$. If $n$ has an odd number of digits, $11|f(n)$ if and only if $11|nn$, where $nn$ is a concatenation of two copies of $n$.
However, if $d$ is the number of digits in $n$ and is odd, then $nn = (10^{d} + 1)n = (10+1)\left|\sum_{i=0}^{d-1}(-10)^{i}\right|n$, so clearly $11|nn$. Thus we have


*

*If $n$ has an even number of digits, $11|f(n)$ if and only if $11|n$.

*If $n$ has an odd number of digits, $11|f(n)$.

A: Numbers are divisible by $11$ if and only if the sum of the odd digits minus the sum of the even digits are divisible by $11$.
If $n$ has an even number of digits then $f(n) = (ab....m)....$.  The sum of the even digits are $2018(a+c+....+l)$  and the sum of the odd digits are $2018(b+c +...+ m)$ and the difference is $2018(a+c+...+l - b-d-....m)$.  As $11$ is prime and does not divide $2018$, then $11|f(n) \iff 11|(a+c+...+l - b-d-....m)\iff 11|n$.
If $n$ has an odd number of digits then $f(n) = (ab...kab....k)....$ written out $1009$ times.  The sum of the even digits are $1009(a+c+....+k+b+d+.....+j)$ and the sum of the odd digits are $1009(b+d+....+j+a+c + ....+k)$.  Then difference is $0$ so $11|f(n)$.
Conclusion:
$f(n)$ is divisible if and only if:  either $n$ has an odd number of digits, or $11|n$
