One 20th-century British prime minister fathered a child while in office: Tony Blair, whose son Leo was born in 2000 during Blair’s premiership. Blair served as prime minister from 1997 to 2007.
The wording is a useful historical boundary test. Lord John Russell fathered sons while prime minister in the 1840s, but that was the 19th century. David Cameron’s daughter Florence was born in 2010, and Boris Johnson’s children Wilfred and Romy were born in 2020 and 2021, respectively, placing those cases in the 21st century.
The count therefore depends on the century in which the child was born, not simply on whether the prime minister served during part of that century. Blair is the only qualifying case for the 20th century among British prime ministers.
A related curiosity is that no female British prime minister has given birth while in office. The broader all-time count of prime ministers known to have fathered children during their terms is higher because it includes Russell, Cameron, and Johnson.