functional version of prime truncation