Factoring big-integer-in-range generation into new function