Extended prime factors function to work beyond powers of 2