Abstract. For a prime p and nonnegative integers j and n let ϑ p (j, n) be the number of entries in the n-th row of Pascal's triangle that are exactly divisible by p j . Moreover, for a finite sequence w = w r−1 · · · w 0 = 0 · · · 0 in {0, . . . , p − 1} we denote by |n| w the number of times that w appears as a factor (contiguous subsequence) of the base-p expansion n µ−1 · · · n 0 of n. It follows from the work of Barat and Grabner (Distribution of binomial coefficients and digital functions, J. London Math. Soc. (2) 64(3), 2001), that ϑ p (j, n)/ϑ p (0, n) is given by a polynomial P j in the variables X w , where w are certain finite words in {0, . . . , p − 1}, and each variable X w is set to |n| w . This was later made explicit by Rowland (The number of nonzero binomial coefficients modulo p α , J. Comb. Number Theory 3(1), 2011), independently from Barat and Grabner's work, and Rowland described and implemented an algorithm computing these polynomials P j . In this paper, we express the coefficients of P j using generating functions, and we prove that these generating functions can be determined explicitly by means of a recurrence relation. Moreover, we prove that P j is uniquely determined, and we note that the proof of our main theorem also provides a new proof of its existence. Besides providing insight into the structure of the polynomials P j , our results allow us to compute them in a very efficient way.