commit c11e5ec3b8f394afda7ffcaf2ff3aebca599f43b parent dc39ca31c4dd65bccaeafda743620b97ece5397b Author: Agastya Chandrakant <acagastya@outlook.com> Date: Mon, 16 Apr 2018 22:14:30 +0530 add Diffstat:
M | s4/fafl/report.md | | | 14 | ++++++++++++++ |
1 file changed, 14 insertions(+), 0 deletions(-)
diff --git a/s4/fafl/report.md b/s4/fafl/report.md @@ -36,6 +36,20 @@ __Refer figure 1 for TM1 which acts as a transducer to find remainder and quotie Consider a natural number `num`. If it is a composite number, it has atleast one factor between two and $\frac{num}{2}$, both inclusive. +What the TM is doing can be summed up in the following JavaScript code snippet: +``` +function checkPrime(num) { + var div = Math.floor(num/2); + while(div > 2) { + if(num % div == 0) + return 0; + div = div - 1; + } + return 1; +} +``` +The above code requires modulo function, which is defined in the above secion, and the steps are provided in the Performance analysis section. A state transition diagram for the above logic can be drawn. + __Refer figure 2 for TM1 which acts as a transducer to find remainder and quotient of two natural numbers__ ### Source code