1. A method of operating a digital computer system and a quantum processor to factor an N-bit integer p as a product of a pair of integers a and b, the method comprising: representing a, b, and p in binary using the digital computer system; decomposing the binary representations of a and b into two respective components (a h , a l ) and (b h , b l ) via the digital computer system; constructing at least three component logic circuits which perform the multiplications of a h b h , a l b l , and (a h +a l )(b h +b l ), respectively, via the digital computer system, wherein each of the at least three component logic circuits includes at least one respective logic gate; encoding each respective one of the at least three component logic circuits which perform the multiplications of a h b h , a l b l , and (a h +a l )(b h +b l ), respectively, as a respective discrete optimization problem using the digital computer system, wherein each respective discrete optimization problem includes a respective set of miniature optimization problems, each miniature optimization problem encoding a respective one of the logic gates from the at least three component logic circuits, and wherein each respective miniature optimization problem is characterized by a respective objective function that is minimized when a truth table of the corresponding logic gate is obeyed; and solving each respective discrete optimization problem using the quantum processor, wherein solving each respective discrete optimization problem gives the components (a h , a l ) and (b h , b l ) of the binary representations of a and b.