Calculate d in the RSA algorithm