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$
3
  • 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$ Commented Sep 15, 2018 at 6:11
  • 1
    $\begingroup$ See: quantumcomputing.stackexchange.com/q/1654/2645 & quantumcomputing.stackexchange.com/q/2346/2645 $\endgroup$ Commented Sep 15, 2018 at 14:37
  • 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$ Commented Sep 15, 2018 at 17:58

1 Answer 1

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$
3
  • $\begingroup$ Are these different from adders as implemented on a reversible classical computer? $\endgroup$ Commented Sep 17, 2018 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$ Commented Sep 18, 2018 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$ Commented Sep 18, 2018 at 1:08

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.