function value = luhn_check_digit_calculate ( s )

%*****************************************************************************80
%
%% luhn_check_digit_calculate() determines the Luhn check digit of a string.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 September 2015
%
%  Reference:
%
%    https://en.wikipedia.org/wiki/Luhn_algorithm
%
%  Input:
%
%    string S, the string of digits to be checked.
%
%  Output:
%
%    integer VALUE, the Luhn check digit for this string.
%
  s_len = length ( s );
  s2 = s;
  s2(s_len+1) = '0';

  value = luhn_checksum ( s2 );

  if ( value ~= 0 )
    value = 10 - value;
  end
  
  return
end
