Smart factorial arithmetic