Appeals to randomness of various number-theoretic constructions are regularly found in scientific publications. It is enough to mention such famous names as V.I. Arnold, M. Kac, Ya.G. Sinai, and T. Tao. Unfortunately, all this comes down to various, although often quite non-trivial, heuristics. I will describe a novel analytical approach to address this question. As an application, the expected positive answer to the question about the randomness of quadratic residues and the unexpected negative answer in the case of prime numbers will be given. Technically, the proposed approach is based on a fundamentally new construction of the entropy of the trajectory of a dynamical system, which is in some way intermediate between the classical Kolmogorov-Sinai metric entropy and topological entropy.