Function and test to obtain the control digit