We have developed a framework to convert an arbitrary integer factorization problem to an executable Ising model by first writing it as an optimization function and then transforming the k-bit coupling ($kgeq 3$) terms to quadratic terms using ancillary variables. The method is efficient and uses $mathcal{O}(text{log}^2(N))$ binary variables (qubits) for finding the factors of integer $N$. The method was tested using the D-Wave 2000Q for finding an embedding and determining the prime factors for a given composite number. As examples, we present quantum annealing results for factoring 15, 143, 59989, and 376289 using 4, 12, 59, and 94 logical qubits respectively. The method is general and could be used to factor larger numbers