{'fraction_non_alphanumeric': 0.04730746352216662, 'fraction_numerical': 0.015395920081178488, 'mean_word_length': 4.074455492424242, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Quantum Abacus for counting and factorizing numbers

We generalize the binary quantum counting algorithm of Lesovik, Suslov, and Blatter [Phys. Rev. A 82, 012316 (2010)] to higher counting bases. The algorithm makes use of qubits, qutrits, and qudits to count numbers in a base 2, base 3, or base d representation. In operating the algorithm, the number n<N = d^K is read into a K-qudit register through its interaction with a stream of n particles passing in a nearby wire; this step corresponds to a quantum Fourier transformation from the Hilbert space of particles to the Hilbert space of qudit states. An inverse quantum Fourier transformation provides the number n in the base d representation; the inverse transformation is fully quantum at the level of individual qudits, while a simpler semi-classical version can be used on the level of qudit registers. Combining registers of qubits, qutrits, and qudits, where d is a prime number, with a simpler single-shot measurement allows to find the powers of 2, 3, and other primes d in the number n. We show, that the counting task naturally leads to the shift operation and an algorithm based on the quantum Fourier transformation. We discuss possible implementations of the algorithm using quantum spin-d systems, d-well systems, and their emulation with spin-1/2 or double-well systems. We establish the analogy between our counting algorithm and the phase estimation algorithm and make use of the latter's performance analysis in stabilizing our scheme. Applications embrace a quantum metrological scheme to measure a voltage (analog to digital converter) and a simple procedure to entangle multi-particle states.


I. INTRODUCTION
The representation of an integer number n and its decomposition into prime factors are basic mathematical operations. Quantum mechanics offers a new perspective on these tasks, as well known since the seminal work of Peter Shor 1 on the efficient factorization of large numbers, with a drastic impact on the security of codes. But even the counting of small numbers and their factorization may prove useful, e.g., in the manipulation of physical number states (and superpositions thereof) or in the entanglement of flying qubits [2][3][4] . A quantum algorithm to count n < N = 2 K particles propagating in a wire using an array of qubits (a K-qubit register) has been proposed recently 4 ; a very similar scheme has been proposed by D'Helon and Milburn 5 in order to find the number state distribution of a vibrational excitation in a system of trapped laser-cooled ions. Besides providing the number n in a binary form (base 2 counting), a simplified version of this algorithm tests for the divisibility of n by 2 k for a given k ≤ K and thus provides the power of 2 in the factorization of n. In the present article, we generalize this algorithm to perform a base d counting and a test for the factor d k in the decomposition of n.
In order to accomplish this goal, we make use of a minimal formulation of the counting task in terms of the problem of distinguishing between different known quantum states in a single-shot measurement. This reduction to a few very basic elements naturally connects the counting task with the quantum Fourier transformation and provides us with a constructive scheme for the setup of a (non-demolition) quantum counting algorithm. We study various possible (hardware) implementations of this algorithm, paying special attention to the case of a ternary (base 3) counting system involving qutrits as elementary counting devices. We establish the relation between our quantum counting algorithm and the phase estimation algorithm and discuss several applications.
Our counting algorithm is inspired by the problem of counting in mesoscopic systems 6,7 and in quantum optics 8 . A straightforward setup counting particles in a non-invasive manner requires of the order of N 2 individual counting elements, see below. A more sophisticated setup providing a unary counting scheme reduces this effort to an order-N process, and a drastic further reduction to a (log d N ) 2 scaling can be achieved when going over to a counting base d.
The base-2 algorithm proposed in Ref. 4 involves two steps, a first (analog) one where a finite train of n charged particles traversing a quantum wire, see Fig. 1, is coupled to an array of K nearby qubits, thereby rotating the states of the qubits in a prescribed manner. In more abstract terms, this step corresponds to reading a number state |n Φ ∈ H Φ in the Hilbert space of number states of particles into a state |Ψ n Q of a K-qubit register in the Hilbert space H Q of the K qubits. More generally, a superposition of number states gets entangled with the Kqubit register (not copied, as demanded by the no-cloning theorem) during the counting process. In a second step, the qubit state in H Q is manipulated and read out, providing either the maximal power of 2 contained in n or the number n in binary form, depending on the readout ing algorithm (shown is the case of base-two counting with qubits). A particle number state |n Φ is fed into a quantum wire to undergo quantum counting. The interaction between the charged particles and the qubits rotates the spin/qubit states, thereby generating the Fourier transformation F taking the initial state F(|0 Q ) into the state F(|n Q ). A suitable manipulation and readout either provides the number state |n Q (this is an inverse quantum Fourier transformation with a subsequent single shot measurement in the computational basis or a semi-classical quantum Fourier transformation involving a sequential measurement) or the maximal factor 2 K in n (this readout involves 'qubit-rotations' followed by a single shot measurement).

algorithm.
The two steps correspond to two quantum Fourier transformations of special kind: expressed in the usual (cf. Ref. 9) computational basis |0 Q = |00 . . . 0 Q , |1 Q = |00 . . . 1 Q , . . . , |2 K − 1 Q = |11 . . . 1 Q ∈ H Q of the Kqubit register, the passage of the n particles in the quantum wire transforms the initial state i.e., the lowest Fourier harmonic of the K-qubit register, into the n-th harmonic the quantum Fourier transform of the state |n Q = |n 1 n 2 . . . n K Q , where n is written in binary form, n = n 1 n 2 . . . n K = n 1 2 K−1 + n 2 2 K−2 + · · · + n K 2 0 , cf. Ref. 9. Depending on the desired information (precise counting or divisibility) and the available hardware (an operating quantum computer or a set of qubits), the readout of the qubit register can be done in various ways. The most efficient version for this second step of the algorithm is the application of a second (inverse) quantum Fourier transformation F −1 on the qubit state F(|n Q ), taking it back into the state |n Q . A simultaneous measurement of the K qubits then provides the particle number n in binary form; in case of a superposition of particle number states, the measurement will execute a projection onto one of them. Alternatively, the number state may be used in a further computation.
However, performing an inverse quantum Fourier transformation on the state F(|n Q ) requires a quantum computer (or at least those qubit operations required in the execution of a quantum Fourier transformation). Instead, we can make use of a procedure which is basically identical to the semi-classical Fourier transform suggested by Griffiths and Niu 10 , a conditional measurement algorithm involving a sequential readout, where the reading of the j-th qubit depends on the results of the previous j−1 measurements. This measurement still provides the full information on a pure number state; if the initial state is a superposition of number states, the semiclassical algorithm will project the state (upon sequential measurements of the qubits) to one of its components.
A specially efficient readout is available if we are interested in the power of 2 contained in n rather than n itself. In this case, a simultaneous (rather then conditional) readout algorithm can be applied directly to the state F(|n Q ); this algorithm then provides a divisibility check of n by 2 k , k < K.
The present article deals with the generalization of this algorithm. The most obvious task to generalize is the determination of other powers of primes in n, i.e., to find the factorization of n, n = 2 k2 3 k3 5 k5 . . . . This can be achieved by going over to generalized qubits, threelevel systems or qutrits, d-level systems or qudits, etc. Equivalently, this corresponds to changing the representation of the number n from binary (base 2) to ternary (base 3), quinary (base 5), etc. Again, the two-step algorithm first transfers the information from the physical number state |n Φ into the computational K-qudit register (→ F(|n Q )) through a particle-qudit interaction and then extracts the information in the qudit register via an inverse Fourier transform (→ |n Q ). This readout step involves a full quantum transform on the level of each single qudit, while a semi-classical transform 10 suffices to extract the information on the level of the K-qudit register.
In order to carry out the above program, it is very helpful to have an abstract understanding of the counting process. Indeed, a minimal abstract formulation of quantum counting in an N -dimensional Hilbert space (allowing to distinguish or count at most N objects) naturally leads us to two types of basis states, the computational basis (corresponding to the states |n Q ), in which the result of the counting process is measured, and the counting basis |ψ n Q where the actual counting process is done-it turns out that just these two basis-sets are naturally related by the quantum Fourier transformation, |ψ n Q = F(|n Q ). Furthermore, the abstract analysis of the counting process provides us with a recipe how the algorithm can be physically implemented.
In the following, we compare the efficiency of various quantum counting algorithms (Sec. II) and then briefly repeat our previous base 2 quantum algorithm with qubits, including the sequential and single-shot readout schemes, see section III. We then present in Sec. IV our basic analysis of the quantum counting process, providing a natural link between quantum counting and the quantum Fourier transformation as well as a constructive scheme helping us to generalize counting to a base d system. We then proceed with the simplest generalization to qutrits in section V, the problem of counting in a base-3 representation or power counting of 3, and discuss its further generalization to qudits. To be specific, we consider an implementation with a three-level system in the form of three quantum dots and also discuss various ideas for other hardware implementations of the base-3 algorithm in section VI, a spin-1 system, serving rather as a Gedanken experiment for illustration, and two practical versions of emulating a qutrit with qubits. In Sec. VII, we discuss an interesting correspondence between our counting algorithm and the phase estimation algorithm 9,11,12 (no such correspondence is yet known for our divisibility check) and apply this insight in the proposal for a quantum voltage-detector (an analog-digital converter). Another application, a scheme to create multi-particle entangled states in a Mach-Zehnder interferometer, is discussed in Sec. VIII. We summarize and conclude in Sec. IX.

II. EFFICIENCY OF QUANTUM COUNTING
In a broader context, the efficiency of our quantum counting algorithm has to be compared with other schemes. E.g., the most straightforward non-invasive way of counting the number of (charged) particles flowing in a wire (directed along x) is to use a spin-counter polarized in the xy-plane and rotating the state by an incremental angle φ = π/N (around the z-axis) upon passage of a particle 6 . This spin rotation is achieved through the magnetic field pulse generated by the passing charge 13,14 ; see also Refs. 8,15 for a related experiment in a quantum optical setup. The precise correspondence of the angle with the number of passed particles then requires an accurate measurement, to a precision of φ = π/N , of the spin-counter's final state polarization-this either necessitates a large number M > N 2 /π 2 of repetitions of the counting experiment, or a single-shot readout of M identical counters all measuring the passage of the particles: Measuring the spin along the y-axis, the (theoretical) probability to find it pointing upwards is given by P ↑ = m ↑ k /M = cos 2 (nφ/2), where m ↑ k denotes the average of finding m ↑ of the M spins pointing up in a sequence of k → ∞ realizations of the entire experiment. On the other hand, the one-time measurement m ↑ m provides the experimental result P ↑ m = m ↑ m /M , from which we can find the number n = (2/φ) arccos[(P ↑ m ) 1/2 ]. As this procedure is a statistical one, we have to determine how many spins (measurements) M are needed to predict the particle number n with certainty. We then require that the difference in probability (we assume N > n 1) δP ↑ = |P ↑ (n + 1) − P ↑ (n)| ≈ |∂ n P ↑ | = (φ/2) sin(nφ) has to be much larger than the uncertainty Given the binomial statistics of the measurement process [the values ↑ and ↓ are measured with probabilities P ↑ and (1 − P ↑ )], we obtain (δm ↑ ) 2 k = P ↑ (1 − P ↑ ) M and combining these results, we find that spins are needed in order to accurately measure the particle number n < N .

III. QUBITS: COUNTING POWERS OF 2
We first provide a more detailed discussion of the base-2 counting algorithm with the setup in Fig. 1, where the n < N = 2 K particles to be counted flow in a quantum wire along x. Single electron pulses can be generated by appropriate voltage pulses 6,16 or through injection from a quantum dot 17 and the counters are conveniently thought of as individual spins, cf. Refs. 6,13,14. We use spin states polarized along the z-axis as our computational basis, | ↑ ↔ |0 and | ↓ ↔ −i|1 .
Preparation: Initially, the K spins or qubits (we use these terms synonymously, cf. Ref. 18) are polarized along the positive y-axis, i.e., the initial states read 2] is identical with the equally weighted sum of K-qubit register states This state then coincides with the lowest harmonic in the Fourier transformed computational basis: indeed, the quantum Fourier transform takes a state into the state with The initial state |Ψ 0 Q of the counting setup then is given by x l = δ l0 and hence |Ψ 0 Q = F(|0 Q ).
Counting and Fourier transformation: Assuming a transverse coupling between the charged particle and the spin, the passage of a particle rotates the spins in the x-y plane. The couplings of the spin counters to the wire are chosen such that the j-th spin is rotated (anti-clockwise) by the amount φ j = 2π/2 j (a rotation by U z (φ j ) = exp(−iφ j σ z /2) with σ z a Pauli matrix). The passage of n particles then rotates the j-th spin by the amount nφ j and thus it ends up in the state [| ↑ j + i exp(2πi n/2 j )| ↓ j ]/ √ 2, where we have dropped the overall phase exp(−πi n/2 j ). Again, we identify | ↑ j ↔ |0 j and | ↓ j ↔ −i|1 j and use the binary representation of integers k = k 1 2 K−1 + · · · + k K 2 0 = k 1 k 2 . . . k K to rewrite the product |Ψ n Q = K j=1 [(|0 j + exp(2πi n/2 j )|1 j /2] over qubit states as a sum over register states, From the comparison with the Fourier transform Eqs. (5) and (6) we find that x l = δ ln , and hence the passage of the n particles (the counting process) takes the state F(|0 Q ) into the n-th harmonic F(|n Q ). We call the states |n Q the computational basis and the transforms |Ψ n Q = F(|n Q ) define the counting basis. The fact that the qubits in the K-qubit register reside in a product state and hence remain unentangled 10,12 is a crucial element of our algorithm and in fact decisive for the next step, the readout of the result with the help of a semiclassical quantum Fourier (back) transformation. Readout and inverse Fourier transformation: Let us then turn to the second step, the semi-classical quantum Fourier (back) transformation which provides us with the desired result, the binary representation of n. We start with the measurement of the first spin: since this has been rotated by the angle nπ, we measure it along the y-axis. If we find it pointing upward, the number's parity is even and we store a '0' in the first position n K of the binary number; in case we find it pointing downward, the parity is odd and we store the digit '1'. Besides providing the number's first binary digit, the parity, the outcome of the measurement also tells us whether the second spin (rotated by nπ/2) is directed along the y-axis (even parity) or along the x-axis. This information allows us to measure the second spin along the correct axis; for an even n, we measure the spin along the y-axis (and store a 0 (1) in n K−1 if the spin is pointing up (down)), while for an odd-parity n, we measure the spin along the −x-axis. The iteration of the readout algorithm is straightforward: the j-th spin is measured along the direction m j−1 φ j with the integer m j−1 = n K−j+2 . . . n K−1 n K corresponding to the binary number encoded in the j − 1 previous measurements. The j-th position in the binary register then assumes a value n K−j+1 = 0 or n K−j+1 = 1, depending on the measurement result, 0 for a spin pointing along the axis and 1 for a spin pointing opposite. This sequential measurement algorithm provides us with the binary representation of n.
In order to render the algorithm more efficient, rather After passage of the particles, the initial state with all spins pointing along the y-axis and corresponding to the lowest Fourier harmonic is transformed to the final state, the n-th Fourier harmonic with properly rotated spins. The indivdiual counter qubits are then measured (M) and the binary digits nj, j = 3, 2, 1 are determined in reverse order. After each measurement, the remaining qubits are rotated (R) to undo the counting of the corresponding moduli: Following the measurement of the first qubit, the rotations by the last (odd numbered) particle are undone. After measurement of the second qubit the rotation by the last odd-numbered pair is undone.
than rotating the axis of measurement, the spins are rotated backwards by the corresponding angles. These rotations by −m j−1 φ j are conveniently done incrementally: after measurement of the j-th spin with outcome '0' or '1', all spins J > j are rotated by −n K−j+1 2 j−1 φ J . These rotations undo the action of odd-numbered groups of particles: The first rotation by −2πn K 1/2 J acting on the qubits J > 1 compensates for the last odd-numbered particle. The second rotation by −2πn K−1 2/2 J acting on the qubits J > 2 compensates for the last oddnumbered pair. The third rotation by −2πn K−2 4/2 J acting on the qubits J > 3 compensates for the last oddnumbered quartet, etc. These rotations make the next spin to be measured point up or down, since the action of those particles giving an intermediate result has been subtracted. The entire algorithm is illustrated in Fig. 2 for the case of n = 7 particles counted by K = 3 qubits. Formally, the availability of a sequential readout algo-rithm can be derived from a suitable representation of the product state Eq. (7): the fraction n/2 j in the phase exp(2πi n/2 j ) of the j-th qubit has to be known only modulo 1 and making use of the relation the j-th qubit state can be written in the form [|0 j + exp(2πi 0.n K−j+1 . . . n K )|1 j ]/ √ 2, where we make use of the binary representation of fractions 0.n 1 n 2 . . . n K = n 1 /2 + n 2 /4 + · · · + n K /2 K , see Ref. 9. The final state after passage of the particles can then be written in the form This representation demonstrates that the state of the first qubit j = 1 involves only the smallest digit n K of the seeked number n, the second one involves the fraction 0.n K−1 n K , and so on. Hence each qubit state requires knowledge of the states of previous qubits and its measurement adds one digit more to the binary representation of n. Divisibility by 2 k : A variant of the above counting algorithm provides a test for the divisibility of n by powers of two. Consider the state of the first j = 1, 2, . . . , k ≤ K spins after the passage of n particles. If the number n contains the factor 2 k , then the k qubits will all point along the positive y-axis (and, for k < K, the k + 1-th qubit will point down; alternatively, if n = 2 K then all spins in the register have returned to their initial state pointing along y). A single-shot measurement of the Kqubit register along the y-axis thus provides the (maximal) factor 2 k in n. The formal proof of this statement is given in Ref. 4.

IV. DISTINGUISHABILITY AND QUANTUM COUNTING
We now reduce the problem of quantum counting to the task of distinguishing between quantum states. This reduction will quite naturally lead us to the definition of two basis sets, one serving the counting process itself by admitting a simple manipulation of phases during the counting step (the computational basis) and the other keeping track of the counting (counting basis); the two are related by the operation of quantum Fourier transformation.
We start from the premise that quantum counting corresponds to the process of associating distinct states of an auxiliary quantum system (the counter) to the size (cardinality) of a physical state. We assume that we want to count at most N objects, hence our auxiliary quantum system shall count the objects modulo N . During the counting process, the initial state |Ψ 0 of the counter is, upon passage of n objects, transformed to the final state |Ψ n (we can safely drop the index Q in this section). We define the unitary operation C 1 to describe the passage of one particle, and a simple iteration produces the state upon passage of n particles. We now require that we can distinguish between the states |Ψ n and |Ψ 0 in a single-shot measurement, implying that the states should be orthogonal, Ψ n |Ψ 0 = 0. So far, we only require that we can distinguish between 'no particles' associated with the state |Ψ 0 and a state with 'some particles n' with 0 < n < N and associated with the state |Ψ n , without being able to decide between different number states with different n's. It turns out that a setup solving this reduced task is also able to distinguish between the different particle number states |Ψ n . Indeed, using Eq. (11) and the fact that Ψ n |Ψ 0 = 0 for all 0 < n < N , we find that (we choose 0 < l < n < N ) and hence the states |Ψ n are all orthogonal and distinguishable. Finally, our wish to count modulo N requires cyclicity, i.e., if the dimension of our auxiliary counter system is given by N , then the cyclicity Eq. (13) follows automatically: Applying C 1 iteratively to the counting states |Ψ n , one finds that all states |Ψ n+1 are orthogonal to the previous states |Ψ l , Ψ l |Ψ n+1 , 0 ≤ l ≤ n < N − 1. Once we arrive at n = N − 1, the last state completing the Hilbert space, the further application of C 1 produces a state |Ψ N = C 1 |Ψ N −1 which has to be a superposition of the previous states, |Ψ N = N −1 n=0 Ψ n |Ψ N |Ψ n . However, since all matrix elements Ψ n |Ψ N = Ψ n |C 1 Ψ N −1 = Ψ n−1 |Ψ N −1 vanish for 0 < n ≤ N − 1, we must have |Ψ N ∝ |Ψ 0 and since C 1 is unitary, we arrive at the result Eq. (13). Otherwise, for a larger dimensionality of the auxiliary system, the condition Eq. (13) has to be imposed as a separate requirement.
In the end, the (minimal) auxiliary counter system is described by an N -dimensional Hilbert space H with orthonormal counting basis |Ψ n ∈ H, n = 0, . . . , N − 1 and Ψ l |Ψ n = δ ln , and a unitary (shift or counting) operator C 1 taking one counting state to the next, C 1 |Ψ n = |Ψ n+1 , and the property of cyclicity, C N 1 = C N = exp(iΘ). In a specific physical implementation, the phase Θ is determined by the dynamical evolution of the system during counting. The states |Ψ n keep track of the numbers in the counting process, i.e., due to their orthogonality they uniquely identify the cardinality of the counted set.
In order to further characterize the properties of our auxiliary counting system, we determine the eigenvalues and eigenvectors of the counting operator C 1 . Expressed in the basis {|Ψ n } N −1 n=0 , the latter assumes the form Its eigenvalues and eigenvectors are easily found: the determinant of C 1 − λ1 1 is given by (−λ) N + (−1) N −1 e iΘ and hence the eigenvalues of C 1 are the N roots of 1 on the unit circle in the complex plane shifted by The associated eigenvector |k is given by Note that a phase Θ = 2πl simply renumbers the eigenvectors and eigenvalues by l.
The eigenstates |k of the counting operator C 1 show a particularly simple behavior in the counting processthey merely pick up a phase, and these phases are distributed homogeneously over the unit circle. Hence, expressing the (unknown) counting states |Ψ n through the eigenstates |k of the counting operator C 1 , we obtain = e i nΘ/N F(|n ).
Making use of the eigenstates |k , the counting step can be implemented in an extremely simple and minimally invasive manner: upon passage of a particle, each state |k shall pick up the additional phase exp[i(2π k + Θ)/N ] and |Ψ n goes over to |Ψ n+1 , which is just the action of C 1 or of counting. Hence, if we choose as our computational basis the set of orthonormal eigenstates {|k } N −1 k=0 of the shift operator C 1 , then the counting process can be implemented in a 'soft' way, adding only phases to the computational states (note that these are the states in which our final projective measurement will be done). At the same time, the counting basis, which is interconnected by the shift operator C 1 , is made from the states |Ψ n = exp(i nΘ/N )F(|n ), which is nothing but the quantum Fourier transform (up to a phase) of the eigenstates |n . In the further general discussion below we set Θ = 0; the required transformation eliminating a finite Θ will be discussed later. At this point one may ask if there are other counting algorithms which do not exploit the quantum Fourier transformation-the answer is yes, but such alternative schemes do not provide the 'soft' counting involving only the addition of phases. As an example, consider the setup Sketch for a real space counter in the form of a 3level qutrit operating in the amplitude mode; the interaction between the counter particle and the particle in the quantum wire is assumed to be attractive (a slightly modified version can be found for a repulsive interaction). Subsequent lowering of the barriers separating the quasi-classical states |0 , |1 , and |2 upon passage of a particle moves the counter particle to the left, cf. (a) → (b) → (c). The third particle passing drags the counter particle all the way back to the initial state, cf. (d).
shown in Fig. 3, a multi-well system (one counter particle in a d-well potential landscape) operating in the amplitude mode. Assuming an attractive interaction 19 , the passing particle lowers or removes the barrier between adjacent semi-classical states, allowing the counter particle to move between two wells. Here, the semi-classical states localized in the individual wells play the role of the counting states |Ψ n : initializing the counter in the (right-most) state |Ψ 0 , cf. Fig. 3, the first d − 1 particles passing will push the counter particle to the left in steps of one, |Ψ n → |Ψ n+1 , while the d-th particle will drag the counter particle back to the right until it ends up in the initial state |Ψ 0 . The difference of this device with the 'soft' counting device discussed above is in the choice of the computational basis: rather than selecting the Fourier transformed states of |Ψ n , which are eigenstates of the shift operator C 1 and only pick up phases during the counting process, here we choose as a computational basis the counting basis itself, hence, |n = |Ψ n . As a result, rather than adding phases during counting, we shift the counter particle in real space. Obviouly, this setup is difficult to realize as quite some fine tuning is required to generate a clean shift operation; furthermore, the shift operation in real space will generate an appreciable back action on the passing particles. On the other hand, such a counter is not supposed to evolve coherently between counting steps, hence the requirements on the coherence time are reduced.
In abstract terms, the counting process can be illustrated through the counting states |Ψ n arranged in a circle with the shift operator C 1 transforming one state to the next. The goal then is to have for the Fourier transformed basis states |k a set of (measureable) states which merely pick up phases when interacting with the passing particles; these states then shall form our computational states. In this basis, the counting process (the shift operator C 1 ) transforms one Fourier mode into the next, cf. Fig. 4(a). So far, the abstract computational states |n have been chosen in a trivial way, without any additional structure; correspondingly, our counting process is still a simple (and inefficient) one, requiring as many different states as we have objects to count. The great reduction in the (hardware) complexity of the counting process appears with the introduction of a counting base. Introducing a counting base d (d = 2 (3) for binary (ternary) counting), we have N = d K and can reduce the hardware requirement from N to log d N = K; correspondingly, the efficiency of the algorithm increases dramatically from a linear in N complexity to log d N . To illustrate the case, we consider a simple example N = 8, d = 2, and K = 3, counting up to 8 with the help of 3 qubits. The primitive version involves a loop with 8 states |0 , |1 , . . . , |7 . This can be reduced to three loops with two states each, |0 j , |1 j , j = 1, 2, 3, cf. Fig. 4. The preparation of the large loop generates the state |Ψ 8, the properly prepared reduced system is in the state |Ψ The counting step on the large loop adds the phase exp(2πik/8), |k → exp(2πik/8)|k , to the state |k in |Ψ . On the other hand, the counting step on the small loops adds sequentially smaller phases: |ν 1 → exp(2πiν/2)|ν 1 , |ν 2 → exp(2πiν/4)|ν 2 , |ν 3 → exp(2πiν/8)|ν 3 , ν = 0, 1. One easily checks that the state (the three entries refer to the qubits 1, 2, and 3, e.g., + e 3iπ/4 |011 + e iπ |100 + e 5iπ/4 |101 + e 3iπ/2 |110 + e 7iπ/4 |111 ]/ √ 8 upon passage of one particle; this is identical to |Ψ upon identifying the state |k with its binary equivalent |k 1 k 2 k 3 . Hence, the complexity of the hardware used in the counting task is easily reduced by going over to a counting base; in our case, rather than implementing an 8-level system, the same counting task can be accomplished with the help of 3 qubits. This step in reduction of complexity is nothing but going over to a (quantum) Abacus, cf. Fig. 4(b). Its physical implementation involves qudits (playing the role of the rows in the classical Abacus); performing one cycle in the j-th qudit shifts the state of the next qudit by one unit. The insight provided by the 'soft counting procedure' and the reduction in hardware provided by choosing a counting base (base 2, 3, . . . , d) described above gives us a recipe how to construct a physical implementation of the counting process: Define a quantum mechanical system with N = d K orthogonal states |k , k = 0, . . . , N − 1, with an identical (trivial) time evolution; these states form our computational basis and often appear in the form of semi-classical (measureable) states. The non-trivial time evolution of these states originates from their interaction with the particles during their passage. The coupling of the states to the particles has to be arranged in a way such that the state |k picks up a phase exp(2πik/N ) upon passage of one particle. Defining the interaction Hamiltonian H int , this implies an equidistant distribution of the matrix elements t k 0 dt k|H int |k ; assuming that all levels interact with the particles during equal time intervals t k = t c , we can conclude that the spectrum of H int is equidistant. Furthermore, returning back to the cyclic phase Θ in the counting operator C 1 , we can compensate for a finite value via an energy shift in the interaction Hamiltonian H int : adding a constant energy Θ /t c to H int , we redefine the counting operator operatorC 1 = e −iΘ/N C 1 and the counting basis |Ψ n = e −iΘ n/N |Ψ n , 0 ≤ n < N , and find that the new condition for the cyclicity reads As a specific example, we can examine the situation for the base 2 counting in Sec. III; here, the Hamiltonian (more precisely, the logarithm of the shift operator, (1/i) ln C 1 ) describing one count can be written in the form where the Pauli matrix σ (j) z operates on the j-th qubit, resulting in the expected equidistant spectrum, cf. Fig.  5. In this example, the energy zero is located in between 2 eigenstates and hence Θ = π. Shifting the zero-energy point to one of the eigenstates, we then can get rid of the cyclic phase Θ; e.g., shifting the energy zero to the top-most level we identify the state | ↑↑↑ with the computational state |0 .

V. QUTRITS: COUNTING POWERS OF 3
As a first step towards the generalization to qutrits, we reformulate the base 2 counting algorithm in terms of manipulations of a particle in a double well potential with semi-classical (computational) states |0 and |1 , cf. Fig. 6(a), as directly realizable with a double-dot charge qubit [20][21][22] .
We assume the double-dot charge qubit to be aligned perpendicular to the wire, such that the two wells couple differently to the charge of the passing electrons, cf. Fig.  6(a). We work with the quasi-classical states |0 ↔ | ↑ and |1 ↔ | ↓ (our computational basis) and consider a 'phase mode operation' of the counter, with a large barrier separating the quasi-classical states, resulting in an exponentially small tunneling amplitude ∝ ∆, with 2∆ the gap between the two true eigenstates. The qubit is manipulated by applying voltage pulses, either to lower the barrier between the two wells in order to change the amplitude (rotation around the x-axis; e.g., opening a gap 2∆ between the qubit eigenstates during the time t = π/2∆ moves the state |0 to the state |1 ) or to disbalance the two wells in order to change the phase (rotation around the z-axis; e.g., lifting the right well by δ during the time t = ϕ/δ adds a relative phase exp(−iϕ) to the state |1 ). The algorithm involves three steps: To prepare the qubit, we start from the semi-classical state |0 and apply the unitary (amplitude-shift) operator A 10 = exp(−iH 10 t/ ) with the tunneling Hamiltonian H 10 = −∆(|0 1| + |1 0|) and the time t = π/4∆ to produce the balanced superposition |Ψ 0 = ((|0 + i|1 )/ √ 2, in a spin language this corresponds to a rotation around the x-axis by −π/2 to produce the initial state | + y . Next, we let the particles pass the (first) counter qubit. Upon passage of one particle, the semi-classical qubit states |ν pick up a phase exp(2πiν/2). The unitary op- the passage of a second particle brings the state |Ψ 1 back to |Ψ 0 , hence C 1 is cyclic, C 2 1 = 1. This operation corresponds to the rotation of the spin by π around the z-axis. The states |Ψ 0 and |Ψ 1 define the counting basis.
Finally, we translate the measuring process. The application of the operator A −1 10 = A † 10 transforms |Ψ 0 back to |0 and |Ψ 1 to |1 (up to a phase); a simple check that the qubit is in the state |0 tells, that the number n of passed particles is even.
The subsequent qubits j > 1 are prepared in the same way. Since it is the task of the qubits j > 1 to detect the passage of groups of particles, these counters are more weakly coupled to the wire. In particular, the operator C 1 for the second qubit measures the passage of pairs, hence the phase added to the state |1 is π/2, and similar for the following qubits. Regarding the final step of measurement, there are two variants: in order to extract the maximal factor of 2 k in n, it is sufficient to apply the operation A † 10 and then check, whether the counter resides in the state |0 ; the first qubit residing in the state |1 determines the power k. On the other hand, if the goal is to find the cardinality n, then before applying A † 10 the qubits have to be properly prepared through a 'rotation around the z-axis' (rather then 'rotating the axis of measurement'). These 'rotations' are conveniently done incrementally and involve a phase shift of the quasiclassical state |1 : after measurement of the j-th qubit with outcome '0' or '1', the measured value is stored as the digit n K−j+1 (note the reversal in the sequence) and all qubits J > j are given a phase shift −n K−j+1 2 j−1 φ J on the state |1 . After application of A † 10 , the qubit j + 1 is measured. An interesting subtlety concerns the possible entanglement of the qubits with the passing particles during counting. The spin counter discussed in section III is entirely unproblematic regarding this aspect, as the gauge interaction leaves the counted particle essentially unchanged. On the other hand, a charge qubit acting as a counter can become strongly entangled with the counted particle: With the qubit charge in a quantum superposition, with 1/2 probability to be closeby the wire (state | ↑ ) and 1/2 probability to be further away | ↓ , the particle passing by is first decelerated and then reaccelerated by the qubit charge. This process happens with different strengths depending on the qubit state. As a result, the particle wave function may split after passing the qubit, with one part (the fast one, |f ) moving ahead of the other (the slow one, |s ). The calculation of the probability P y to find the counter state pointing along the y-direction is given by the partial trace over the particle space; if the two states |f and |s are distinguishable, f |s = 0, then P y = 1/2 independent of the phase φ picked up by the counter qubit. Hence, it is crucial that the counter does not generate a wave function splitting when the particle passes by, i.e., the counter only works properly if |f ≈ |s and the final state is essentially non-entangled. Using the charge qubit as a measuring device, the requirement of weak splitting boils down to the condition 23 φ ξk F , where φ is the angle of the qubit rotation quantifying the qubit-particle interaction, k F is the Fermi wave vector in the quantum wire, and ξ is the width of the wave packet.
In a more quantitative analysis, we can consider the evolution of a (Lorentzian, cf. Ref. 16 to the scalar field of a charge qubit. For simplicity, we assume that the state |0 acts with a potential V (x) on the wave function, while the state |1 , which is further away from the wire, has no influence on the particle. Furthermore, we choose the potential V (x) such that the qubit state is rotated by φ, i.e., after the passage of the particle, the initial qubit state |Ψ 0 = (|0 + i|1 )/ √ 2 shall be rotated into the state |Ψ φ = (e iφ |0 + i|1 )/ √ 2. Assuming a smooth potential V (x), we determine the asymptotic particle-qubit state within a semi-classical approximation and project the wave function onto the qubit state |Ψ φ ; tracing over the particle degree of freedom, we find the probability P φ = 1−φ 2 /8k 2 F ξ 2 to measure the qubit in the state |Ψ φ and the second term provides the probability to observe a wrong result. Note that the error probability involves the square of the small parameter φ/ξk F .
The base 3 counting with qutrits in the form of triple wells follows the same scheme as the base 2 counting with double-dot qubits described above. We start out with one qutrit counter, i.e., K = 1, which initially resides in the state |0 , cf. Fig. 6(b). First, the qutrit is prepared in a balanced state with equal weights in each of the three semi-classical ground states (the phases may be chosen arbirarily). The (amplitude-shift) operators A 10 and A 21 performing this task generalize the operator A 10 above. The angle χ 10 = ∆ 10 t/ in the operator A 10 (we write the matrices in the semi-classical basis), =   cos χ 10 i sin χ 10 0 i sin χ 10 cos is chosen such that 2/3 of the wave function is shifted to the state |1 , hence tan χ 10 = √ 2. The matrix A 10 then assumes the form The operator A 21 transfers weight between states |1 and |2 , Its task is to take the state A 10 |0 = (|0 + i √ 2|1 )/ √ 3 to the balanced state |Ψ 0 = (|0 + e iϕ1 |1 + e iϕ2 |2 )/ √ 3 (with approriate phases ϕ 1,2 ). Choosing the time such that χ 21 = ∆ 21 t/ = π/4 we obtain the operator and the balanced state |Ψ 0 = A 21 A 10 |0 reads We call the combination U p ≡ A 21 A 10 the preparation operator. The particular construction of the state |Ψ 0 does not produce the lowest Fourier harmonic |Ψ h = [|0 + |1 + |2 ]/ √ 3; if we insist to work with the canonical expression for the Fourier transformation, we have to properly redefine the phases of the computational basis states, |0 → |0 , |1 → −i|1 , and |2 → −|2 . Otherwise, we can actually start our counting basis with any Fourier harmonic of the computational basis or even with any other balanced state as it is produced in a convenient physical preparation step (as we have done above). Also note that our preparation operator U p is not acting as a Fourier transformation on the other basis states but is a simpler operator that only transforms the state |0 into a properly balanced state.
We come to the readout step. We define the inverse preparation operator U −1 p ≡ [A 21 A 10 ] −1 = A † 10 A † 21 ; using the explicit forms in Eqs. (22) and (25) we obtain the expression The application of U −1 p takes the state |Ψ 0 back to |0 , while U −1 p |Ψ 1,2 are still superpositions of the semiclassical states |1 and |2 , The divisibility test by 3 then involves the application of U −1 p to the state C n 1 |Ψ 0 obtained after passage of the n particles and a measurement of the qutrit state; if the qutrit resides in the state |0 , then n is divisible by 3.
Finding the modulus of n to the base 3 is slightly more involved. We have to rotate the states U −1 p |Ψ 1,2 such as to recover the original states |1 and |2 of the computational basis. Using the spin language in the twodimensional space spanned by |1 and |2 , this operation is achieved by a 'rotation' by π/2 around the zaxis, followed by a rotation by −π/2 around the x-axis.
The former operation is executed by the phase operator P 2 ≡ exp(i(π/2)|2 2|), while the latter is noting but the operation A 21 . The combination then determines the modulus of n, since Depending on the outcome |0 , |1 , or |2 after the measurement of the qutrit, the number n is divisible by 3 modulo 0, 1, or 2. The modulus can be found with a sequential measurement scheme: after application of U −1 p and measurement of the state |0 , the outcome tells that the modulus is 0 (if the particle is found in state |0 ) or 1 or 2 (if the particle is not detected); in the latter case the operator A 21 P 2 is applied and the measurement of well |1 will provide the final result, with a modulus 1 if the particle is detected in state |1 and a modulus 2 if it is not found (then the particle resides in state |2 ).
In the above derivation, we have adopted those phases which naturally appear in the simplest manipulation of the three-well system-as a result, the matrix Eq. (34) is not the canonical (inverse) Fourier transform. The following steps (for the general case with N counting states) then relate the obtained matrix M with the canonical form of F −1 . Chosing phases α k in the definition of eigenstates |k of the counting operator C 1 , we interrelate the counting and computational bases through Second, let us assume that our physical manipulations have produced a measurement operator M such that Then the measurement operator M and the canonical inverse Fourier transform F −1 are related via with the unitary (phase) operators The generalization of the algorithm to K-qutrit registers follows the same steps as above. We assume that all elements in the K-qutrit register initially reside in the state |0 j , i.e., the state of the register encodes the state |0 Q of the computational basis. The qutrits j > 1 serve the counting of particle clusters: the qutrit j counts groups of 3 (j−1) particles, hence the elementary phase shift in C 1 is exp(2πi/3 j ). Correspondingly, subsequent qutrits are each coupled to the wire a factor 3 less than the previous. Let us go through the algorithm: the preparation of the j-th qutrit is identical to the first one. Upon passage of a particle, the semi-classical states |ν in the j-th qutrit pick up phases exp(2πiν/3 j ).
The readout for the divisibility check involves the application of U −1 p to all K qutrits and subsequent test for the semi-classical state |0 j in each qutrit: if all qutrits j < k + 1 reside in |0 j and the qutrit j = k + 1 does not, then n is divisible by 3 k .
In order to recover the number n in the base 3 representation, the qutrit states need to be corrected for the passage of incomplete groups of particles before application of M, Eq. (34), except for the first one, which is directly measured after application of M. The result 0, 1, or 2 of the measurement is stored in n K . Before measuring the next qutrit j = 2, all counters J > 1 need to be corrected for the modulus of n: The states |ν of the J-th qutrit are given the additional phase shifts −2πn K ν 1/3 J . Subsequently, the operator M is applied to the qutrit j = 2, its state is measured, and the result 0, 1, or 2 is stored in n K−1 . Iterating the process, the result n K−j+1 of the measurement of the j-th qutrit is used to correct for the passage of incomplete groups of 3 j particles by adding phases −2πn K−j+1 ν 3 j−1 /3 J to the states |ν of the qutrits J > j. After application of M to the qutrit j + 1, its state is measured and the result is stored in n K−j .
Let us briefly analyze the three operators U p , U −1 p , and M: since U p merely takes the state |0 into the balanced state |Ψ 0 (but does not act as a Fourier transformation on the others), its inverse U −1 p does not describe an inverse quantum Fourier transformation. Only after augmentation of U −1 p to the measuring operator M, cf. Eq. (34), we arrive at the required inverse quantum Fourier transformation allowing for the readout of the individual qutrit states. The subsequent readout of the qutrit register does not require a fully quantum inverse transformation, rather, the semi-classical version using sequential measurements and manipulations (executing the compensation for the passage of incomplete groups of particles) is sufficient. Below, we will encounter other implementations, where the preparation operator U p already acts as the complete quantum Fourier transformation on the semi-classical computational states |n ; in this case the measurement operator is trivially given by M = U −1 p . The reason for sticking to two different oper-ators U p and M −1 in the above discussion is due to the simplicity of the preparation step when using U p . This is particularly advantageous in the case where one is interested in the divisibility of n by a power 3 k , as the readout only involves the inverse operator U −1 p . Using the full Fourier transformation M −1 for the preparation instead leads to a much more difficult hardware implementation of the preparation, cf. the following section V A.

A. Generalization to qudits
The further generalization to base-d counting with qudits follows the same ideas as those developed for the base-2 and base-3 counting with qubits and qutrits. In order to set up the algorithm, we have to define the three steps 'preparation through U p ', 'counting with C 1 ', and 'measurement' with the inverse Fourier transformation M. The first two steps are clear: the preparation of the initial balanced counting state |Ψ 0 starts from the computational state |0 and proceeds with the subsequent shift of weight in the wave function to the neighboring well, always leaving behind an amplitude with weight 1/ √ d; the individual steps involve the operators with the (k − 1, k) non-trivial 2 × 2 block shifting the amplitude between the wells k − 1 and k, cf. Eq. (20). This operation is physically implemented through lowering the barrier between two neighboring wells k − 1 and k. Similarly, the counting operator C 1 is given by the straightforward generalization of Eq. (27) involving the rotation-or phase-operators with φ = 2πk/d and implemented through changing the gating bias of the well k.
The implementation of the inverse Fourier transformation M with the help of the physical operators Eqs. (39) and (40) is more difficult but still possible, since this set of operations (gates) is universal, i.e., given a unitary d×d matrix, it can be constructed from a product of operators made from A χ k,k−1 and P φ k . The proof of this statement is similar to the proof of the universality of two-level unitary gates, cf. Ref. 9: Given an unitary d × d matrix (or operator) U, the idea is to reduce U in an iterative procedure to the unit operator by right-multiplication with amplitude and phase operators. E.g., consider the entries U 0,k−1 = β = |β|e iϕ β and U 0,k = α = |α|e iϕα in U (we number rows and columns with indices from 0 to d − 1). The product U P φ k−1 A χ k,k−1 generates the new entries β e iφ cos χ+iα sin χ and α cos χ+iβ e iφ sin χ and we can replace the new entry at the position (0, k) by 0 if we choose the angles χ = arctan(|α/β|) and φ = π/2 + ϕ α − ϕ β (if β = 0 then χ = π/2, φ = 0 and α = 0 implies zero angles). The new (0, k − 1) entry reads β = ie iϕα |α| 2 + |β| 2 . Repeating this step d − 1 times we replace the top row by zeros, except for the (0, 0) entry, which we bring to unity with an additional phase operation. Hence 2d − 1 elementary amplitude and phase operations take the first row to the vector (1, 0, 0, . . . , 0) and a total of d 1 (2k − 1) = d 2 elementary operations take the unitary operator U to unity; the desired operator then is obtained by a simple inversion.
In order to illustrate the procedure, we derive the Fourier transform M −1 , for the qutrit. In the implementation of the first step we find the angles χ = arctan(1) = π/4 and φ = π/2 and the product M −1 1 = M −1 P π/2 1 A π/4 2,1 produces the matrix The angles for the second step read χ = arctan( √ 2) and φ = π and we obtain the matrix M −1 Next, the angles for the third step read χ = π/4 and φ = π/2 and the product M −1 2,1 generates the second row in the form (0, 1, 0) already-no further phase rotation is needed in this step. Finally, we have to compensate for the phase of the (2, 2) matrix element, which is done by the additional rotation , and we arrive at the unit matrix. Collecting all factors, we obtain the measurement operator M expressed through elementary shift and phase operators, The result Eq. (44) corresponds to the expression Eq. (34) up to phases. Indeed, above, we have presented a minimal algorithm with a preparation step U p generating the first computational state with phases (1, i, −1) instead of the canonical ones [the trivial phases (1, 1, 1)]. As a result, the final measurement operator Eq. (34) corresponds to the inverse Fourier transform up to phases. Of course one could easily introduce additional phase operations P φ k and remove the non-canonical phases (with , however, such additional gates only render the algorithm more involved. Also, it is important to note that the divisibility check does not require the implementation of the inverse Fourier transformation and hence it is worth while to know how to implement a minimal preparation operator U p .

VI. IMPLEMENTATIONS OF QUTRITS AND QUDITS
The base d counting and factorization algorithm obviously requires a set of suitable and well operating elementary quantum devices, qubits, qutrits, or qudits. Starting out from qubits and their analogy with a spin-1/2 system, the most natural generalization is to try a spin-1 system for the implementation of qutrits and possibly a spin-d system for the qudits; although this idea can be realized in principle for the case of a spin-1 system, the preparation and measurement algorithm is rather complex (see below) and should be viewed as a Gedanken experiment rather than a realistic proposal. The next idea then is to generalize the concept of the double-dot charge qubitthis road has been pursued above and works fine in theory, however, the implementation of multi-dot charge qubits may turn out difficult. As an alternative, one may try to emulate a d-spin qudit (d-level system) by a system of spin-1/2 qubits (two-level systems). Provided we admit two-qubit interactions in our manipulation scheme, we then are able to define all the necessary operations required by the algorithm. Hence, we can offer a scalable route for the implementation of qudits using qubits as elementary units. Below, we will discuss the various issues related to the implementation of qutrits and qudits in more detail, putting our main emphasis on the understanding of the qutrits, their implementation and manipulation.

A. Spin-1 qutrit
The most straightforward attempt to generalize the base 2 counting with qubits (spin-1/2 two-level systems) to the base 3 counting with qutrits makes use of a spin-1 three-level system with the orthogonal (computational) basis |l, m z = |1, 1 z = |0 , |1, 0 z = |1 , and |1, −1 z = |2 , where l and m denote the angular momentum and magnetic quantum numbers. As in the previous cases (two-level qubit, three-level qutrit), we have to prepare the system in the initial counting state Ψ 0 , e.g., the lowest harmonic of the computational basis or another balanced state. The logic taking us to a valid balanced state is the following: i) we first note, that experimentally we can produce either axial states (polarized along a direction n) such as |1, 1 n , or planar polarized states |1, 0 n , hence we will focus on these types of states. ii) As one cannot construct axial states with equal weights for all basis states |0 , |1 , |2 , we concentrate on the planar states. iii) the most general planar state (with a director parallel to n defined by the direction angles ϕ and θ) assumes the form (in the computational basis) We demand that all components have equal weights, hence θ = arctan √ 2; choosing ϕ = π/4, we obtain the balanced state the planar state |1, 0 ec with a director e c = (1, 1, 1)/ √ 3 pointing along the body diagonal; other values of ϕ correspond to another direction e c rotated around the z-axis.
The other counting states then are obtained by rotating |Ψ 0 by the angle 2π/3 (anti-clockwise) around the z-axis, |Ψ 1 = U z (2π/3)|Ψ 0 and |Ψ 2 = U z (2π/3)|Ψ 1 ; physically, this rotation is achieved by ensuring that passing electrons create a local magnetic field pulse along the z-axis. To simplify our further discussion, we exchange the two axes, the one for the preparation and the one defining the counting field: our task then is to generate an initial planar polarized state |1, 0 z and implement the counting step through rotation by an angle 2π/3 (anticlockwise) around the axis e c .
While the creation of axially polarized states is rather straightforward, creating a planar polarized state |1, 0 n is non-trivial. Indeed, while we can make use of a simple deterministic procedure to prepare an axially polarized state (by switching on a magnetic field and relaxing the spin through coupling to a bath), the planar polarized state required here is more difficult to obtain. A simple preparation can be implemented with the help of a Stern-Gerlach apparatus, however, this procedure is a statistical one, with a one-half probability for a positive outcome. In fact, preparing an initial state polarized along x, |1, 1 x = (|1, 1 z + |1, −1 z )/2 + |1, 0 z / √ 2, using a Stern-Gerlach setup directed along z, and selecting particles with a straight trajectory (i.e., selecting the 'middle spot' in the Stern-Gerlach setup) we obtain the desired spin state |1, 0 z (a procedure to generate a proper initial state with unit probability is discussed later).
With the counting state |Ψ 0 = |1, 0 z properly prepared, we define the counting step through a rotation by the angle 2π/3 around the axis e c = (1, 1, 1)/ √ 3, cf. After preparation in the state |1, 0 z , the system is in a state of planar (xy) polarization, i.e., the spin has no component along z. Upon passage of a particle, the polarization plane is rotated (by the angle 2π/3 around ec) from xy to yz, for the second particle to zx, and for the third back to xy. The divisibility test involves a measurement with a Stern-Gerlach apparatus with the field directed along the z-axis.

7,
As the three-fold iteration takes us back to the original state |1, 0 z , our counting operator is cyclic and generates the complete orthogonal counting basis The measurement step for the divisibility check after the passage of the particles involves a second Stern-Gerlach experiment directed along the z-axis-if the particle moves again on the straight trajectory, its polarization was unchanged by the passage of the n particles and hence n is divisible by 3. The other states give no contribution to the signal on the straight trajectory, cf. Fig. 8.
As usual, the measurement of the number's modulus (the counting measurement) is more involved. We then make use of the other outcomes |1, 1 z and |1, −1 z of the second Stern-Gerlach experiment and bring them to interference further down their trajectories, cf. Fig.  8. Testing the resulting state, e.g., the state |1, 0 y = i(|1, 1 z + |1, −1 z )/ √ 2 (we choose symmetric trajectories with equal phases) in a third Stern-Gerlach apparatus polarized along the y-axis then identifies the counting state |1, 0 y on the straight trajectory (the middle spot, the number's modulus is 2); if no spin is measured, the counting state |1, 0 x has been realized and the number's modulus is 1. Sending the initial polarized state |1, 1 x into a first Stern-Gerlach (SG) apparatus with axis z and selecting the middle (undeflected) trajectory, we obtain the planar state |1, 0 z with probability 1/2. The counted particles passing by rotate this state around the axis ec = (1, 1, 1)/ √ 3 and generate the planar counting states |1, 0 z , |1, 0 x, and |1, 0 y (note that the counter particle has to be stopped and trapped during the time of interaction with the particles passing by). These are analyzed in a second SG apparatus with axis z-if the spin is not deflected, the number n of counted particles is divisible by 3. Combining the two deflected beams and analyzing the superposition in a further SG apparatus directed along the y-axis, we find the mudulus of n, which is 2 if the spin is undeflected and 1 else.
Finally, we look for a preparation step with unit efficiency. This can be achieved by making further use of the states |1, ±1 z behind the first Stern-Gerlach device (we still use the input state |1, 1 x to the Stern-Gerlach apparatus): superimposing these two states, we obtain the component i(|1, 1 z + |1, −1 z )/2 = |1, 0 y / √ 2 and rotating this planar state back to the z-axis, we have managed to transform the initial spin |1, 1 x into two subsequent wave-packets with weight 1/2, each describing the same spin state |1, 0 z . Hence, although we cannot generate a planar state out of an axial state by simple rotation, the use of a Stern Gerlach apparatus and proper manipulation of all three amplitudes of the split wave function allows one to generate the desired planar state, though split into two wave-packets with weight 1/2 each.
Obviously, the above scheme is a very complex one and should be regarded as a 'Gedanken' experiment rather than a realistic setup. Nevertheless, it is interesting to see, that a spin-1 qubit can, at least in principle, be used for the implementation of the base-three counting algorithm.

B. Triple-dot qutrit
The triple-dot qutrit has been discussed above in section V. Preparation, counting, and readout can be properly implemented via voltage pulses acting on the semiclassical states (phase shifts) or on the barriers in between (amplitude shifts). A drawback is the need to design a new device when going from base 2 to base 3 counting and, more generally, each time a new prime factor is to be tested. The emulation of qutrits (and qudits) through qubits described below allows one to stay with only one computational unit for all base-d counting tasks and factorizations.

C. Emulation of spin-1 qutrit
The basic idea we pursue here is to emulate the qudits needed in the base-d counting and factorization through simpler qubits. We start by combining 2 qubits into a qutrit.

Emulation using a spin triplet
An obvious way to choose three appropriate states in the product Hilbert space H 1/2 ⊗H 1/2 of the two qubits is to make use of the decomposition into singlet and triplet sectors, and use the three-dimensional triplet space H 1 . Contrary to the simple spin-1 qutrit, the emulated version using two qubits provides us with the necessary degrees of freedom to perform all of the required steps (preparation with U p and readout with M) in the counting and factorization algorithm with the help of one-(σ (i) x , σ (i) z ) and two-qubit (σ (1) z σ (2) z ) operations. Referring to the previous paragraph, we start from the computational basis |0 = | ↑↑ , |1 = (| ↑↓ + | ↓↑ )/ √ 2, and |2 = | ↓↓ and seek for those manipulations which provide us with the counting states in the form of three orthogonal planar polarized states with balanced weights. The latter take the form Eq. (45), whereas the axial states can be written as (again in the computational basis) with n the direction of the spin axis. Note that once these states are chosen, the operators σ (i) z and σ (1) z σ (2) z only change the relative phases in |1, 0 n and |1, 1 n but not the relative weights in the amplitudes. It is then our task to construct three orthogonal planar states out of the computational basis, which consists of two axial and one planar state. In this way, we can find a preparation operator U p which is congruent to the Fourier transformation, i.e., U p = M −1 transforms the computational basis {|k }| 2 k=0 into the counting basis {|Ψ n }| 2 n=0 . We first note, that the planar states Eq. (45) always have the same weight in the components |0 and |2 and hence we first have to rotate the axial states of the computational bases into the xy-plane. This is done with the operator e iπσx/2 where σ x = (σ (1) x + σ (2) x )/2 and results (up to a phase) in the states [θ = π/2 in Eq. (50)] cf. Fig. 9. Note that the simple rotation takes the planar state |1 into a planar state (with a director along y). In order to map the axial states in Eq. (51) to planar states we choose θ = π/4 in Eq. (45) and obtain the candidate states the planar and axial states in Eqs. (52) and (51) now have equal amplitudes. In order to select the appropriate phases ϕ in the planar states Eqs. (52), we note that the phase differences between the |0 and |2 components of the axial states are equal to ±π; these have to be matched with the phase differences π −2ϕ in the planar states and hence we choose planar states with ϕ = 0, π, The two states are characterized by directors pointing along the xz-diagonals, cf. Fig. 9. In order to map the axial states Eq. (51) to the planar states Eq. (53) we make use of the two-qubit operator The latter adds the phases χ (−χ) to the components |0 , |2 (|1 ) and hence leaves the relative phase between the components |0 , |2 unchanged while adding a relative shift −2χ to the middle one. Hence choosing χ = −π/4, we can map the axial state |1, 1 ey to the planar state |1, 0 x,z and |1, 1 −ey to the planar state |1, 0 x,−z , cf. Fig. 9. Since the component |1 in the planar state |1, 0 ey has weight 0, the operator U −π/4 leaves it unchanged.
Hence we have arrived at three orthogonal planar states directed along y and along the xz-diagonals; a final rotation e iϕσx with σ x = (σ (1) x + σ (2) x )/2 by ϕ = arctan(1/ √ 2) around the x-axis then arranges the three states symmetrically around the z-axis. Combining the three operations, we obtain the preparation and inverse measurement operator The actions of the three operations in Eq. (55) on the computational basis states {|n }| 2 n=0 are illustrated in Fig. 9; the resulting counting basis is given by the three (planar) states |Ψ n = U p |n , One can confirm, that the counting step involving the application of the operator C 1 = exp(2πi σ z /3) with σ z = (σ (1) z +σ (2) z )/2, indeed transforms the three counting states in Eq. (56) into each other, i.e., |Ψ n = C n 1 |Ψ 0 = C n |Ψ 0 (note the symmetric definition of σ z used here and compare with the corresponding definition of C 1 in the following paragraph, section VI C 2).

Efficient emulation
Although the emulation of the qutrit by the triplet sector of two qubits can be done consistently, this scheme is inefficient in scaling up to larger primes. Indeed, emulating a spin-2 system within this scheme requires 4 qubits, whereby most of the Hilbert space (an eleven dimensional sector) is not used since only the component H 2 out of the decomposition is needed. A suitably scalable case should make maximal use of the emulating qubits, i.e., use a large fraction of the Hilbert space. In choosing the appropriate subset of states in the multi-qubit Hilbert space, we have to select states with an equidistant spectrum. E.g., for the case d = 3 and 2 qubits, we choose three consecutive states from |0 = | ↑ ↑ , |1 = | ↑ ↓ , |2 = | ↓ ↑ , |3 = | ↓ ↓ and an elementary phase shift operator ; upon passage of a particle, the four states then pick up the phases exp(−3iλ/2), exp(−iλ/2), exp(iλ/2), and exp(3iλ/2). Choosing λ = 2π/3 and the first three states |0 , |1 , and |2 , the (relevant sector of the) operator C 1 , coincides with the expression Eq. (27), up to an overall phase exp(3iλ/2) = exp(iπ) [to be added to (58)]. The generalization of this scheme to an E-qubit emulation of a qudit is straightforward, In addition to the shift operator C 1 , we need to know the form of the preparation operator U p . For the above qutrit emulation, this operator takes the form (see Appendix A for the derivation) (2) x /4 e iπσ (1) e iπσ (2) x /4 e iπσ (1) z /4 e iθσ (1) x /2 with the angle θ = 2 arctan(1/ √ 2). As this is not yet the full Fourier transformation on the computational basis |k , k = 0, 1, 2, we still have to find the measurement operator M. In order to accomplish this task, one notes that the three counting states |Ψ n , n = 0, 1, 2 are entangled, while the three computational states |k , k = 0, 1, 2 are not. The inverse Fourier transformation M then has to disentangle the counting states, a criterion which helps us in finding its explicit form. In the end, the measurement operator M is obtained in the form of a product of three unitary operations U i , i = 0, 1, 2, where U 2 and U 1 serve to disentangle the three counting states |Ψ n , n = 0, 1, 2, and U 0 is a conditional Hadamard operation, turning the spin of qubit 2 into the z-axis if the qubit 1 is in the state | ↑ . The detailed derivation of Eqs. (60) and (61) and the form of the operators U i , i = 0, 1, 2, is given in Appendix A.

VII. RELATION TO PHASE ESTIMATION ALGORITHM AND ITS APPLICATION
It turns out, that our counting algorithm has much in common with the phase estimation algorithm (PEA); the following discussion of the PEA is formulated in a way as to make this connection apparent. The phase estimation algorithm first appeared as a part of Shor's factorization algorithm 1 ; an extended separate algorithm was presented by Kitaev 11 and later by Cleve et al. 12 . The phase estimation algorithm attempts to find the 'phase' 0 ≤ ϕ < 1 in the eigenvalue exp(2πiϕ) of a unitary operator U associated with a given eigenvector |u . In the version of Refs. 9,12, this is achieved with the help of two qubit-registers, one of which (the second) is storing the vector |u and acts on it with the operators U 2 j−1 , j = 1, . . . , K, to generate the phases exp(2πi 2 j−1 ϕ). The other (first) register consists of K qubits and produces the desired phase estimate in the following manner: with all qubits initialized in the state |0 j , a Hadamard operation generates the balanced states (|0 j + |1 j )/ √ 2 for all qubits in the first register. A controlled U 2 K−j operation between the second register and the j-th qubit in the first register then puts the qubit into the state (|0 j +exp(2πi 2 K−j ϕ)|1 j )/ √ 2, hence generating the quantum Fourier transform (we express the product state through the computational basis and assume that the phase ϕ can be represented by K binary digits) in the first register. A final inverse Fourier transformation then generates the state |2 K ϕ Q |u and the projective measurement of the K-qubit register in the computational basis provides us with the phase ϕ; for an arbitrary phase 0 < ϕ < 1 we obtain a K-binary-digit estimate ϕ dig of the phase ϕ.
Comparing this algorithm with our counting setup, we identify the action of the n particles traversing the quantum wire with the action of the second register in the PEA, with the correspondence |n Φ ↔ |u . The controlled U 2 j operation in the PEA is replaced by the coupling of the wire to the qubits: the interaction of the n particles with the last (K-th) qubit has to be identified with the action of the controlled U operator in the PEA, hence ϕ = n/2 K . The qubits j < K are more strongly coupled to the wire, that corresponds to higher powers of the operator U in the PEA; in fact, the j-th qubit coupling is enhanced by the factor 2 K−j and its interaction with the particles in the wire corresponds to the action of the controlled U 2 K−j operator. Finally, the intermediate states in Eqs. (9) and (62) agree with one another with the identification n/N = n/2 K ↔ ϕ. The final states exhibit the correspondence |n Q |n Φ ↔ |2 K ϕ dig Q |u . Note that our divisibility algorithm has no counterpart in the PEA.
This analogy immediately allows us to profit from the performance analysis 9,12 of the PEA: Assume that we wish to measure the phase ϕ in the PE problem to an accuracy of 1/2 A (i.e., we want to encode ϕ with A bits) and be sure of our measurement result with a probability P = 1 − at least, then the setup must involve K = A + log 2 (2 + 1/2 ) qubits.
This result can be applied to our counting algorithm. Consider the case, where a non-integer number x = n+δn has passed the counter, with n an integer and 0 < δn < 1 a real number. Such a situation may occur when the interaction between the particles and the counting qubits is still finite at the moment when the readout procedure starts, corresponding to the passage of a fraction of a full charge. Concentrating first on the implementation with a fully-quantum inverse Fourier transformation, the performance analysis of the PEA tells us that we still can measure the number to any desired precision. E.g., if we want to be able to measure the number n < N = 2 K such that |n meas − x| < 1/2 with a probability P = 1 − 2 −r , we need to be able to resolve fractional charges δn ∼ 2 −r 1, i.e., we have to add additional qubits which measure half-charges (turning by 2π on the passage of one particle), quarter charges (rotating by 4π), etc. The entire setup then has to involve ≈ K +log 2 (1/2 −r ) = K + r qubits. This result can be extended to qudits: requiring a precision P = 1 − d −r , we need ≈ K + log d (1/d −r ) = K+r qudits. Hence, we can trade additional qudits in the counting process against a higher probability to obtain a correct integer result.
Next, we consider the semi-classical inverse Fourier transformation; we demonstrate below that this semiclassical scheme exhibits the same stability as the fullyquantum version, although the passage of a fractional charge strongly affects the conditional measurement of subsequent qubits, e.g., for δn = 1/2 the measurement of the first qubit gives a random input for the direction of measurement of the second qubit. However, this error does not propagate through the entire measurement scheme. Instead, the measurements of higher qubits recover from false results measured for lower qubits. Formally, this can be proven by comparing the two probabilities P qF (n; x) (using a full quantum Fourier transformation) and P scF (n; x) (using a semi-classical Fourier transformation) to find the integer number n when a noninteger number x has passed by the qubit register.
Indeed, let us calculate the probability P scF (n, x) to find the integer result n = K j=1 n j 2 K−j upon measurement of a non-integer signal x by the qubit register. The probability p 1 (n K , x) that the first qubit provides the value n K is given by the matrix element between the qubit state (|0 1 +e 2πix/2 |1 1 )/ √ 2 and the state (|0 1 +e πin K |1 1 )/ √ 2 to be measured (i.e., the projection | + y 1 for n K = 0 or | − y 1 for n K = 1, cf. Sec. III) Next, the conditional probability to measure the value n K−1 for the second qubit is given by the product p 1 (n K ; x)p 2 (n K−1 , n K ; x) with p 2 (n K−1 , n K ; x) = |( 2 0| + e −πi(n K−1 +n K /2) 2 1|) (|0 2 + e 2πix/4 |1 2 )| 2 /4. (64) Using Eq. (8), we can rewrite the first factor in p 2 (n K−1 , n K ; x) in the simpler (and equivalent to the second factor) form (65) The straightforward iteration of this scheme then produces the final result for P scF (n, x) in the product form where (67) Evaluating the product, the result Eq. (66) is easily rewritten in the form P scF (n, x) = | Q Ψ n |Ψ x Q | 2 with the generalized counting state (cf. Eq. (2)) Expressing the counting state |Ψ n Q as a Fourier transform of the computational state |n Q ), |Ψ n Q = F(|n Q ), we arrive at the result P scF (n, x) = | Q n|x Q | 2 , where |x Q = F −1 (|Ψ x Q ) is defined in terms of the back transformed counting state. But this is nothing else than the probability P qF (n, x) to find the number n in a one-shot measurement of the qubit register after application of an inverse quantum Fourier transformation on the detected state |Ψ x Q , hence P scF (n, x) = P qF (n, x). We conclude that the semi-classical and the fully-quantum Fourier transformation exhibit the same stability to systematic errors introduced by incomplete (non-integer) counting. Furthermore, we note that the semi-classical algorithm is rather robust with respect to random errors; the latter can be handled with a classical multi-qubit error correction scheme combined with a simple majority rule, cf.

Ref. 4.
A. Quantum metrology: voltage measurement The above discussion allows us to use our counting device to measure continuous variables. The insight paves the way for its use as a quantum voltage-detector, a particular form of an analog to digital converter (ADC). Consider a setup similar to the one in Fig. 1  the wire replaced by a finite metallic object, see Fig. 10.
Assuming that the applied voltage translates into a relative shift δ K = α K eV (δ 1 = α 1 eV ) of the most weakly (strongly) coupled qubit [which is the qubit j = K (j = 1)], the reading of the qubit array after detaching the voltage provides us with a binary digital number n which translates into the phase ϕ according to provided that the quantity 2α 1 eV t/h can be represented by an integer number. In order to handle successfully the general case with an arbitrary drive V t, we have to add additional qubits in order to arrive at a digital estimate of ϕ: for a result with a relative precision 1/2 K and with a probability better than 1 − , we need a measuring device with K + log 2 (2 + 1/2 ) qubits. The sensitivity of our quantum ADC improves as 1/t, where t is the time of observation; this is because the accumulated phase increases linearly in time, while the most sensitive qubit always resolves phases of π. The precision then is by a factor 1/ √ t better than the usual classical sensitivity, which scales as 1/ √ t, and agrees with standard expectations 25 . In particular, using the straightforward algorithm described in Sec. II to measure a voltage V < V max = π /eτ with an accuracy δV , we either need M = (π/φ) 2 = (V max /δV ) 2 qubits or have to run repeated experiments over a time t = M τ , where τ is the measuring time of the individual experiment. Solving for the desired accuracy δV , we obtain the scaling δV ∼ V max /et, i.e., the precision improves only with the square-root of the overall measuring time t, the same as for the usual classical case.

VIII. MULTI-PARTICLE ENTANGLEMENT
Another application of our counting device is the generation of multi-particle entangled states with the help of a Mach-Zehnder interferometer, see Fig. 11. Injecting particles into the device through the lower left arm, the splitter generates a superposition of number states in the two arms of the interferometer; measuring the counter placed near the upper arm and selecting a particular reading projects the system to the desired entangled state. The functionality of the device has been described in detailed in Ref. 4 before. Here, we use the device with our qutrit counter to generate the original GHZ (Greenberger-Horne-Zeilinger) state 24 and to unveil in more detail the entanglement between the counter states and the physical number states in the quantum wire; the generalization to other cases with more particles and counters follows the previous discussion in Ref.

4.
Consider a particle entering the Mach-Zehnder interferometer from the lower-left lead and propagating along one of the two leads U or D, see Fig. 11. The wave function can propagate along two trajectories, the upper arm U where the particle picks up a phase ϕ U and the counter is activated, or the lower arm D accumulating a phase ϕ D and leaving the counter state unchanged. The total wave function evaluated at the position A then assumes the form where t and r denote the transmission and reflection coefficients of the beam splitter and we have introduced a pseudo-spin notation to describe the propagation of the particles along the two arms: a pseudo-spin ⇑ (⇓) refers to the particle propagating in the upper (lower) arm. The qutrit state depends on the particle's trajectory and reads either |Ψ 1 if the particle has passed in the nearby upper arm or |Ψ 0 if the particle passed through the lower arm of the interferometer. Next, we inject three particles (from the bottom left) into the Mach-Zehnder (MZ) loop. We assume the three individual wave functions describing the initial state to be well separated in space, allowing us to ignore exchange effects in our (MZ) geometry. The wave function at the position A then reads Ψ 3A = t 3 e 3iϕ U | ⇑, ⇑, ⇑ + r 3 e 3iϕ D | ⇓, ⇓, ⇓ ⊗ |Ψ 0 +tr 2 e i(ϕ U +2ϕ D ) | ⇑, ⇓, ⇓ + | ⇓, ⇑, ⇓ +| ⇓, ⇓, ⇑ ⊗ |Ψ 1 +t 2 r e i(2ϕ U +ϕ D ) | ⇑, ⇑, ⇓ + | ⇑, ⇓, ⇑ +| ⇓, ⇑, ⇑ ⊗ |Ψ 2 .
Assuming scattering coefficients for a symmetric beam splitter, e.g., tt * = 1/2, r 2 = (−1)/2, and r t * = ±i e −iϕt /2 (with ϕ t the transmission phase), the projection to the counter state |Ψ 0 provides one with the GHZ-like state |Ψ GHZ = (| ⇑, ⇑, ⇑ ∓ i e 3i(ϕ D −ϕ U −ϕt) | ⇓, ⇓ , ⇓ )/ √ 2; manipulation of the flux Φ in the Mach-Zehnder loop then allows one to implement the desired entangled state. Furthermore, the wave function Eq. (71) unveils the entanglement between the (split) number states and the counter. Note that the indistinguishability of particles exploited in the above entanglement process is an 'artificial' one defined by the qutrit detector, rather than the 'fundamental' one of identical particles.

IX. DISCUSSION AND CONCLUSION
Summarizing, we have generalized the binary (base 2) quantum counting algorithm and divisibility test by 2 k to ternary (base 3) and higher counting systems. This extension is quite non-trivial in several respects: On the device level, the qubits used in the base 2 algorithm have to be replaced by qutrits for a ternary counting system and to qudits for a base d algorithm. Since the algorithm is based on two subsequent quantum Fourier transformations, suitable manipulation schemes have to be defined in order to implement a quantum Fourier transformation on the level of individual qubits, qutrits, and qudits. Furthermore, rather than developing new hardware for every new counting base, we have discussed how to use qubits in order to emulate qudits, with particular emphasis on the qutrits.
Starting from binary counting with qubits, it seems not immediately clear how to generalize the concept. It turns out, that defining the quantum counting task on an elementary level through a one to one correspondence between the counting objects and distinguishable states in a Hilbert space provides us with a constructive scheme how this task can be achieved. Also, the analysis of the unary counting scheme naturally introduces the quantum Fourier transformation as the basic operation in a nondemolitian counting process. Indeed, the task of counting naturally introduces a shift operator C 1 in the counting space, taking one counting state |Ψ n Q into the next |Ψ n+1 Q . When expressing these counting states through the eigenstates |n Q of C 1 , then the counting operation only adds a phase exp(2πin/N ) to each of these states. Hence using these eigenstates |n Q , which are nothing but the Fourier transforms of the counting states |Ψ n Q , as our computational basis provides for us a 'soft' nondemolitian counting scheme. Choosing another computational basis involves an energy exchange between the counted object and the counting system and introduces a much more severe perturbation.
The aforementioned basic understanding of quantum counting has provided us with a constructive scheme for the counting algorithm: starting out with a set of measureable states (the computational basis {|n Q }) which evolve with a prescribed phase accumulation upon the passage of particles, we have to prepare out of them a balanced state |Ψ 0 Q which is used as the first counting state. With the appropriate phase increment picked up during counting, this first counting state evolves to the next and returns to the first one after an N -cycle. As we have seen, we do not have to enter the cycle in the lowest harmonic, any harmonic will do, and even arbitrary phases in a balanced state (an equal-weight superposition of the computational basis states) are acceptable. In the latter case, the Fourier transformation is modified with additional phases, which are not harmful to the algorithm, however.
Equipped with this general scheme, we have been able to generalize the binary algorithm to a ternary and to base-d counting. We have seen, that one possible straightforward extension of the hardware, going from a spin-1/2 to a spin-1 system, poses severe problems due to the lack of suitable operators in the state preparation. Indeed, although any superposition of two states are allowed in quantum mechanics, it might be difficult to prepare this superposition in practice. E.g., if we want to superpose two different eigenstates of the same Hamiltonian, one has to act on the states with an operator which might not be available in the given physical system; this situation is actually encountered in the spin-1 system. However, emulating a spin-1 system through the triplet sector of two qubits provides a viable alternative: the two-qubit operation combined with single-qubit rotations provide sufficient degrees of freedom to carry out all required operations for counting, the state preparation and the inverse Fourier transformation. Further emulation of qudits with qubits, however, should not be done in the spin-d sector, as this is a waist of resources. Instead, a straightforward sequence of neighboring energy states will do. An important element to realize is that the Fourier transformation, which we can handle semiclassically 'between' the qudits, has to be fully quantum 'within' the qudits. Hence the larger the chosen counting basis d is, the larger is the part of the inverse Fourier transformation which is done fully quantum.
We have demonstrated, that the substitution of the semi-classical inverse Fourier transformation for the fullyquantum does not entail any disadvantage for the counting algorithm; this is an important result, both with respect to the stability of the counting algorithm against systematic errors (non-integer counting) as well as its application in metrology. It thus appears that the conditional operation in the quantum Fourier transform can be fully substituted by a measurement combined with a conditional operation in the semi-classical scheme. In both cases, a non-integer reading may affect some of the last digits of the seeked number, but the leading digits are not compromized. Furthermore, adding additional qubits (digits) allows to trade an extension of the hardware for a better precision in the output.
In terms of applications of our counter, we have generalized the scheme producing multi-particle entanglement in a Mach-Zehnder interferometer and have proposed its use as a quantum voltage-detector, a particular example of an analog-digital converter. We may speculate that our quantum counting scheme can be generalized to other broadband measurement algorithms and thus contribute to other applications in quantum metrology 25 .
We thank Klaus Ensslin, Alexei Kitaev, Gerald Milburn, Renato Renner, and Peter Shor for discussions and acknowledge financial support by the Pauli-Center at ETH Zurich and the Russian Foundation for Basic Research under grant No. 08-02-00767-a.