The p-value is the probability of a quantile in some distribution. One uses the cumulative distribution function (CDF) for the distribution model (e.g., normal distribution) to obtain the probability for a given quantile (e.g., data value or sample statistic). The CDF is the definite integral from negative infinity to the quantile x of the distribution probability density function (PDF). How these quantiles are used depends on the question and the distribution.
You can use the probability functions in a column formula or in a script window. For example, the lower one-tailed p-value for a t quantile of -3 with a sample size of 10 is:
t Distribution( -3, 9 )
0.00747818195520711
For example, the p-value for the F quantile of 4 used in a one-way ANOVA for testing the mean of 3 groups, each with 8 observations is:
1 - F Distribution( 4, 2, 21 )
0.0337383327150672
I hope that this information helps. I can't say more without more details about your question. Why do you want to know the 'equation/algorithm?' How will you use this information?