And further
Iterating though with values for k, a correct value for d is found when a whole number result for d (no fractional part) is found.
The algorithm used is to first test the user entered value in the form. If this satisfies the equation, it is the d value used. If it does not, it is used as the seed value for 'k'. If the 'd' value is left blank in the form, the algorithm will iterate using k==1 as its start value.
Note that if the value 'e' is not co-prime to phi,
this script may never find a valid value for 'd'.
A limit of 10,000 iterations has been placed on this for the time being.
It has been left this way to show the importance of these
numbers being co-prime, for the RSA system.