# How to add scalar to quantum string

I need a way to add scalar values to a quantum string.

Say if $$| v \rangle = |1 1 0 \rangle + |1 0 1 \rangle$$ then $$|v \rangle + 5 = |1 0 1 1 \rangle + |1 1 0 0\rangle$$

Is there a known method to do this?

I don't want tot express 5 as a qubit string in order to save qubits.

• A vector and a scalar are different dimensions. I don't think you can add them. – Victory Omole Sep 10 '19 at 17:16

Generally you have to perform the addition modulo some constant; you can't grab another qubit if you need to overflow. Code for modular addition of a constant is available in the Increment.qs file in the Q# standard library, in the IncrementByInteger operation. Check out the documentation here.