Prime factorization algorithm based on parameter optimization of Ising model