We present a quantum algorithm to transform the cardinality of a set of
charged particles flowing along a quantum wire into a binary number. The setup
performing this task (for at most N particles) involves log_2 N quantum bits
serving as counters and a sequential read out. Applications include a
divisibility check to experimentally test the size of a finite train of
particles in a quantum wire with a one-shot measurement and a scheme allowing
to entangle multi-particle wave functions and generating Bell states,
Greenberger-Horne-Zeilinger states, or Dicke states in a Mach-Zehnder
interferometer.Comment: 9 pages, 5 figure