# Quantum Modular Adder over \(GF(2^{n}-1)\) without Saving the Final Carry
## 4 Implementation and Results of the Simulation  
To assess our quantum modular adder accuracy over \(GF(2^{n}-1)\), we simulated a quantum circuit using IBM ProjectQ [35]. ProjectQ provides a full-stack software framework for writing and running the proposed quantum algorithms in Python as a high-level domain-specific language. It also provides the various back-ends, which run circuits on a simulator and quantum hardware, such as the default simulation back-end and the IBM Quantum Experience back-end. There are seven back-ends on quantum hardware, such as the \(2^{n}-1\) and \(2^{n}-1\) quantum circuits, and the \(2^{n}-1\) quantum circuits. Figure 11: The optimized quantum circuit for the proposed quantum modular adder over \(GF(2^{n}-1)\) with the sub-modules \(AT\) and \(FA\), and additional element gates instead of \(SZ\) in Figure 9.  
Figure 12: The optimized quantum circuit for the proposed quantum modular adder over \(GF(2^{n}-1)\) in the unit gate level. Figure 13: An example of the optimized quantum circuit in the elementary gate level, where \(n=5\). as ibmqx2, ibmq_16_melbourne, ibmq_armonk, imbq_athens, ibmq_santiago, ibmq_lima, and ibmq_quito. The ibmq_16_melbourne has 15 qubits, the ibmq_armonk has one qubit, and others have five qubits, while the default simulation back-end can simulate numerous qubits. We used the default simulation back-end because we needed 16 qubits when \(n=5\), as shown in Table 1. Through this simulation, it was possible to confirm the accuracy when \(n=5\) by measuring the register \(|b_{i}>\) as a result \(|s_{i}>(i=0,...,n-1)\). For getting the circuits as one of the results based on this ProjectQ, the CircuitDrawer back-end instead of the default simulation back-end helped save and return the circuit by LaTeX code, as shown in Figures 10 and 13. We also evaluated the cost of the proposed quantum circuits. The cost for a quantum circuit mainly includes the number of qubits, the number of CCNOT gates, and the depth, which is the number of gates that can be run in parallel [36]. In all these measures, a lower value implies better performance and less cost. Table 2 shows these for Cuccaro et al. 's adder-based modular adder called C-AM [37], [PERSON] et al. 's Adder-Mod, called V-AM [11], our referenced modular adder OurR in Figure 9, and our optimized modular adder OurO in Figure 11, respectively. Since there is no adder of Cuccaro et al. for modular \(2^{n}-1\), we evaluated the C-AM by applying [PERSON] et al. 's adder to the sub-module \(FA\) of [PERSON] et al. 's Adder-Mod, as shown in Figure 2. Our optimized modular adder OurO has the lowest complexity for the number of qubits, gates, and depth. The number of qubits for OurR and OurO is about \(n\) less than that of the C-AM or the V-AM. By comparison to the V-AM, the number of gates and the depth for OurR and OurO indeed appear much less. OurO has about 3.34 and 1.67 times lower gate than them, as well as has about 3.75 and 1.25 times lower depth than them. Figure 14 visually shows the number of qubits, gates, and depth for different \(GF(2^{n}-1)\), where \(n=1,...,9\). If \(n=5\), we can conclude the following, as listed in Table 1:  
* The number of qubits for OurO was six qubits less than V-AM. * The number of gates for OurO was 26 gates, showing a 71.1% decrease from V-AM. * The depth for OurO was 39, showing a 73.6% decrease from V-AM. * The cost dropped tremendously thanks to reducing the number of qubits, the number of gates, and the depth by the proposed quantum circuit. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Modular Adder** & **Qubits** & **CCNOT Gates** & **Depth** & **Circuit for \(GF(2^{n}-1)\)** & **Simulation** \\ \hline V-AM & \(4n+2\) & \(20n-10\) & \(30n-2\) & Y & N \\ C-AM & \(3n+2\) & \(10n-5\) & \(10n+38\) & N & N \\ OurR & \(3n+1\) & \(8n-7\) & \(10n-4\) & Y & Y \\ OurO & \(3n+1\) & \(6n-4\) & \(8n-1\) & Y & Y \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Comparison of the quantum modular adders based on the ripple carry adder.