<commit_before>const MATH_PI = Math.PI.toString().replace(".", "");

function PI(digits) {

    if (digits <= MATH_PI.length) {
        return MATH_PI.substring(0, digits);
    }

    var x = []
      , r = []
      , j = 0
      , i = 0
      , q = 0
      , carry = 0
      , num = 0
      , dem = 0
      , nums = []
      ;

    for (; j < digits; ++j) {
        x[j] = 20;
    }

    for (; i < digits; ++i) {
        carry = 0;
        for (j = 0; j < digits; ++j) {
            num = parseInt(digits - j - 1);
            dem = parseInt(num * 2 + 1);
            x[j] += carry;
            q = parseInt(x[j] / dem);
            r[j] = parseInt(x[j] % dem);
            carry = q * num;
        }
        nums.push(
            parseInt(x[digits - 1] / 10)
        );
        r[digits - 1] = parseInt(x[digits - 1] % 10);
        for (j = 0; j < digits; ++j) {
            x[j] = r[j] * 10;
        }
    }

    return nums.join("");
}

module.exports = PI;
<commit_msg>JSDoc comment<commit_after>// Constants
const MATH_PI = Math.PI.toString().replace(".", "");

/**
 * PI
 * Calculates the first *n* decimals of PI number.
 *
 * @name PI
 * @function
 * @param {Number} digits The number of decimals of the PI number.
 * @return {String} The PI decimals.
 */
function PI(digits) {

    if (digits <= MATH_PI.length) {
        return MATH_PI.substring(1, digits);
    }

    var x = []
      , r = []
      , j = 0
      , i = 0
      , q = 0
      , carry = 0
      , num = 0
      , dem = 0
      , nums = []
      ;

    for (; j < digits; ++j) {
        x[j] = 20;
    }

    for (; i < digits; ++i) {
        carry = 0;
        for (j = 0; j < digits; ++j) {
            num = parseInt(digits - j - 1);
            dem = parseInt(num * 2 + 1);
            x[j] += carry;
            q = parseInt(x[j] / dem);
            r[j] = parseInt(x[j] % dem);
            carry = q * num;
        }
        nums.push(
            parseInt(x[digits - 1] / 10)
        );
        r[digits - 1] = parseInt(x[digits - 1] % 10);
        for (j = 0; j < digits; ++j) {
            x[j] = r[j] * 10;
        }
    }

    return nums.slice(1).join("");
}

module.exports = PI;

{'fraction_non_alphanumeric': 0.17503454629203133, 'fraction_numerical': 0.022570244127130355, 'mean_word_length': 1.3180362860192103, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5847398', 'n_tokens_mistral': 862, 'n_tokens_neox': 807, 'n_words': 203}