  It is a classical observation that lacunary function systems exhibit many
properties which are typical for systems of independent random variables.
However, it had already been observed by Erd\H{o}s and Fortet in the 1950s that
probability theory's limit theorems may fail for lacunary sums $\sum f(n_k x)$
if the sequence $(n_k)_{k \geq 1}$ has a strong arithmetic ''structure''. The
presence of such structure can be assessed in terms of the number of solutions
$k,\ell$ of two-term linear Diophantine equations $a n_k - b n_\ell = c$. As
the first author proved with Berkes in 2010, saving an (arbitrarily small)
unbounded factor for the number of solutions of such equations compared to the
trivial upper bound, rules out pathological situations as in the
Erd\H{o}s--Fortet example, and guarantees that $\sum f(n_k x)$ satisfies the
central limit theorem (CLT) in a form which is in accordance with true
independence. In contrast, as shown by the first author, for the law of the
iterated logarithm (LIL) the Diophantine condition which suffices to ensure
''truly independent'' behavior requires saving this factor of logarithmic
order. In the present paper we show that, rather surprisingly, saving such a
logarithmic factor is actually the optimal condition in the LIL case. This
result reveals the remarkable fact that the arithmetic condition required of
$(n_k)_{k \geq 1}$ to ensure that $\sum f(n_k x)$ shows ''truly random''
behavior is a different one at the level of the CLT than it is at the level of
the LIL: the LIL requires a stronger arithmetic condition than the CLT does.
