Suppose we have a string of lenght $l$. We uniformly choose a point with distance $0\leq d\leq l$ from one end of the string, and make cuts of this measure until we're left with a piece smaller than $d$. What fraction of the original string should we expect the remaining piece to represent?
That is, for a number $a$ chosen with uniform distribution over the interval $[0,1]$, we look for the expected value of the remainder $1\mod a$.
I unsucessfully tried to solve this analitically, so I decided to write a small python program which gave me the approximate result $\approx0.177$. The interesting part (and main motivation for writing this question) came when I generalized the problem for a value of $a$ in the interval $[0,k]$, while still computing the expected value of $1 \mod a$. This value, of course, approaches one for large $k$, but for small values of $k$ the answer is not a strictly increasing function of k. Instead, the plot shows fractal-ish bumps on the entire interval from 0 to 1 before it stops and becomes strictly increasing.
My question is, is there a way to compute such values? And is there an explanation for the weird bumps for the plot when $k$ is in the interval $[0,1]$?

For your original question about the average value of $1 \bmod a$ where $a \in (0,1]$ the graph below shows the behavior of $1 \bmod a$ with $a$ on the $x$ axis and $1 \bmod a$ on the $y$ axis. The steps come about because we cross values of $\frac 1n$. When $a \gt \frac 12, 1 \bmod a=1-a$. When $a$ drops below $\frac 12, 1 \bmod a=1-2a$. The slope of the second segment is $2$ and in general the slop of the $n^{th}$ segment is $n$. It is a series of line segments from $(\frac 1n,\frac 1n)$ to $(\frac 1{n-1},0)$ for $n=2,3,4,\ldots$ The segment from $(\frac 1n,\frac 1n)$ to $(\frac 1{n-1},0)$ has length $\frac 1{n-1}-\frac 1n$ and average height $\frac 1{2n}$ so the integral of the curve, which is the average height, is $$\sum_{n=2}^\infty\frac 1{2n}\left(\frac 1{n-1}-\frac 1n\right)=1-\frac {\pi^2}{12}\approx 0.177533$$