function cdf = benford_cdf ( x )

%*****************************************************************************80
%
%% BENFORD_CDF returns the Benford CDF.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    03 March 2016
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer X, the string of significant digits to be checked.
%    If X is 1, then we are asking for the Benford probability that
%    a value will have first digit 1.  If X is 123, we are asking for
%    the probability that the first three digits will be 123, and so on.
%
%    Output, real CDF, the Benford probability that an item taken
%    from a real world distribution will have the initial digit X or less.
%
  if ( x <= 0 )
    cdf = 0.0;
  elseif ( i4_is_power_of_10 ( x + 1 ) )
    cdf = 1.0;
  else
    cdf = log10 ( x + 1 );
    cdf = mod ( cdf, 1.0 );
  end

  return
end
