I am currently working on Qiskit code implementing Shor algorithm in the form of a quantum circuit. I am factoring $N = 21$ (into 3 and 7) using 5 qubits, with 3 qubits in the work register and 2 in the control. The purpose is that a random integer between 2 and 20 (inclusive) will be input and the program will either use classical or quantum+classical computing to derive the factors. One thing I noticed as I was creating the circuit was that if a random number is input into the quantum subroutine, say the number 4, and there is no modular exponentiation function, just an inverse QFT on the work register, it still works and finds the period $r$, which is 6. I originally assumed this was a bug or a coding mistake, but it also made me wonder if the modular exponentiation is the same for each input.
Due to this, I have two questions: Is there a universal series of gates that can transform $x$ into $a^x \mod N$, the control register output? I was under the impression it was different depending on what $x$ was, but the results I am getting are seemingly disproving that. Similarly, for numbers as small as $N=21$, does the control register output even matter? The work register output from the inverse QFT appears to be doing all of the work, no matter if the mod. exp. function is included or not?
Picture below, approx. same for every input that reaches the quantum subroutine of Shor's algorithm in my code: