If you want to see the raw functions, go to, f.ex., find_nth_prime 1.1 -> states.c You can also download any folder and, in Linux/Ubuntu, compile it with the instruction
gcc -g main.c turing.c states.c turing.h states.h const.h -o main
and run it in the Linux command line with
./main
To do this, you will have to be in the appropriate folder, which you can change by using the command
cd ./Foldername/Subfoldername/Subsubfoldername
In Windows, compile it and run it with the compiler of your choice.
There is also an animation at: https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=42
***
Below is a transcription of my notes, which are dry but should be easy to understand. The states are gradually defined as the Turing machine moves, and then modified when it makes sense to do so.
// Excursus: After competing this project, I searched for similar ones, and found one by a William Bernoudy. My finding the nth prime TM had 14 states and 12 symbols, while his had 14 states and only 10 symbols. But if I replace state 0 by state 3, I have one state less! Anyways, from now on no state is state 3. We modify state 2, which refers to it.
The 5 will be cahnged to a 6 once we change the 2 that corresponds to the 8. If there is no such 2, n = m. So we modify state 4 and 5 and create a state 6.
This reads: The initial n=2, after which there are enough 7s to increase n to find divisors of m.
Q: But, how many 7s?
A: Well, a priori at least sqrt(n), but up to n, if you one.
Q: But Nuño, if you put ceil(sqrt(n)) '7's, aren't you offloading some of the calculations to yourself instead of making the machine calculate it?
A: Yes, I am.
Anyways, right now the only state which can accept is state 2, which does so if ¬(n|m) for a given n. Instead of accepting, we want to increase n by 1. We modify state 2, and create 2 new states: state 7 and state 8.
state 2:
- if it reads a 2: write 4, move left, change to state 0.
- if it reads a 9: write 9, move left, change to state 7.
- else: move to the right
state 7:
- if it reads a 6: write 5, move left, keep state.
- if it reads a 4: write 2, move left, keep state.
- if it reads a 3: write 1, move left, keep state.
- if it reads a 0: write 0, move right, change to state 8.
state 8:
-if it reads an 8: write 1, move right, keep state.
-if it reads a 7: write 8, move right, change to state 3.
- if it reads a 2: ACCEPT. There is no space left, at least one of each pair of divisors has been tried