Below you will find descriptions and details for the 3 formulas that are used to compute probabilities (p-values) for a chi-square test.

Cumulative distribution function (CDF) for the chi-square distribution:

Gamma function:

Lower incomplete gamma function: