2
$\begingroup$

I have programmed in C++, but I am interested in writing quantum programs. I have some experience with Microsoft's Q#, and I know about the canonical Shor's and Grover's algorithms.

Can anyone tell me how to write a quantum program to add two integers?

$\endgroup$
  • 2
    $\begingroup$ Hi and Welcome to QuantumComputing.SE. We prefer questions, where some effort has been done already. Please show us what you have already tried or searched for. $\endgroup$ – MEE - Reinstate Monica Sep 15 '18 at 6:11
  • 1
  • 2
    $\begingroup$ The title for your question was "writing a program in Q#" but your question's body asks how to add two integers, so I've changed your title. Now you're at risk of having the article marked as a duplicate, because people have asked how to add 1+1 in Q# before. $\endgroup$ – user1271772 Sep 15 '18 at 17:58
4
$\begingroup$

You will need quantum circuits called adders.

You have for example one from Cuccaro et al. and another from Himanshu et al.

$\endgroup$
  • $\begingroup$ Are these different from adders as implemented on a reversible classical computer? $\endgroup$ – ahelwer Sep 17 '18 at 23:32
  • $\begingroup$ I do not know how those are implemented on reversible classical computers (generally not considered) but it is possible that it was the inspiration. They adapt in quantum operations the addition bit-wise but trying to minimize the number of extra qubits and the complexity of the circuit. As the circuit is unitary, you can apply this with superposition. $\endgroup$ – cnada Sep 18 '18 at 0:18
  • $\begingroup$ There are also some links to adders in the Q# online documentation on docs.microsoft.com/en-us/quantum/quantum-formoreinfo. $\endgroup$ – Alan Geller Sep 18 '18 at 1:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.