As a practice exercise, I am trying to factor $N=14$ using Shor's algorithm. My initial guess is $a = 5$, and I need a quantum circuit $U$ for:
$U\vert y \rangle = \vert 5 \cdot y ~{\rm mod}~ 14 \rangle$ for $y=1, 2, \cdots, 13$, i.e. for $y=0001, 0010, ... , 1101$. The modular arithmetic yields the table:
01 0001 0011
02 0010 0110
03 0011 1001
04 0100 1100
05 0101 0001
06 0110 0100
07 0111 0111
08 1000 1010
09 1001 1101
10 1010 0010
11 1011 0101
12 1100 1000
13 1101 1011
The qiskit examples give a circuit for $N=15$, and I was able to find a similar circuit for factoring $N=6$ by trial and error. $U\vert y \rangle = \vert 5 \cdot y ~{\rm mod}~ 6 \rangle$ is reproduced by:
Clearly, trial and error isn't going to work for $N=14$. Is there a systematic method that will provide the circuit I am looking for?