On my phone, no access to YouTube. So I can’t see the other formula (and I tend to avoid video tutorials of subjects that I could read about more quickly).
This site – How to Calculate Pearson Correlation Coefficient: 9 Steps – says it’s sum((x - x_mean) * (y - y_mean)) / ((n - 1) * x_stddev * y_stddev). That’s what my code is doing. I only folded the terms of the numerator sum, x standard deviation sum and y standard deviation sum into one loop (iterate once instead of three times).