2

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?

Mithrandir24601
  • 3,687
  • 2
  • 22
  • 43
quantomm
  • 31
  • 1
  • 2
    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. – luap42 Sep 15 '18 at 06:11
  • 1
    See: https://quantumcomputing.stackexchange.com/q/1654/2645 & https://quantumcomputing.stackexchange.com/q/2346/2645 – user820789 Sep 15 '18 at 14:37
  • 2
    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. – user1271772 No more free time Sep 15 '18 at 17:58

1 Answers1

4

You will need quantum circuits called adders.

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

Sanchayan Dutta
  • 17,497
  • 7
  • 48
  • 110
cnada
  • 4,754
  • 1
  • 8
  • 21
  • Are these different from adders as implemented on a reversible classical computer? – ahelwer Sep 17 '18 at 23:32
  • 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. – cnada Sep 18 '18 at 00:18
  • There are also some links to adders in the Q# online documentation on https://docs.microsoft.com/en-us/quantum/quantum-formoreinfo. – Alan Geller Sep 18 '18 at 01:08