Let D be a Krull domain admitting a prime element with finite residue field and let K be its quotient field. We show that for all positive integers k and 1<n1≤…≤nk there exists an integer-valued polynomial on D, that is, an element of Int(D)={f∈K[X]∣f(D)⊆D}, which has precisely k essentially different factorizations into irreducible elements of Int(D) whose lengths are exactly n1,…,nk. Using this, we characterize lengths of factorizations when D is a unique factorization domain and therefore also in case D is a discrete valuation domain. This solves an open problem proposed by Cahen, Fontana, Frisch and Glaz.