replace factorial by linear