I've been trying to mess around with Qiskit's implementation of Shor's algorithm, and while trying I've noticed that Shor(33), for example, would not output a solution (even with an absurd number of attempts). Qiskit's implementation would retry by itself, so I went on to find an implementation which would give me more control over what's happening and I found this one (https://oreilly-qc.github.io/?p=12-1).
The thing I'm struggling to understand is why, for a given value of a in the modulo function of which Shor attempts to find the period r, and assuring that a has no common factors with the number we're factoring, the period should be found (given a number of tries) and thus the algorithm should succeed. However, Shor(33), with a = 2, does not output any result - just like what happened with Qiskit's implementation. It outputs the correct result, however, when a=5 (33 = 11 * 3). Is there a mathematical explanation for why this happens?
Thank you in advance, I'm quite new to this whole new concept and am just trying to understand this algorithm properly!