Which one is the correct formula to found b variable from OLS? I got a formula that is from the slides of class that is:

So, because I couldn't fully understand I wanted to look the formula in the web, but I didn't get that one.
But instend, its this the formula that it appear.

This is a little more easy to comprehend. I've tried to understand the first one, but couldn't.
When I use the same values get differents outcomes.
I've used 4 points

And got 0.3386882129 For the first formula and  0.247972973 for the second one.
Some my dubt is, this are two formulas for different things, Or could it be that the second formula is misspelled?

These give the same answer when I do it, and they should.
set.seed(2023)
N <- 5
b1 <- function(x, y){
  n <- length(x)
  return(
    (sum(x * y) - n * mean(x) * mean(y))
    /
    (sum(x^2) - n * (mean(x))^2)
  )
}
b2 <- function(x, y){
  
  return(
    (sum((x - mean(x)) * (y - mean(y))))
    /
    (sum((x - mean(x))^2))
  )
  
}
x <- c(3, 55, 15, 17)
y <- c(1.4, 2.2, 4.5, 5)
b1(x, y) # = -0.01119501
b2(x, y) # = -0.01119501

In both equations, the numerator represents the covariance between $X$ and $Y$, and the denominator represents the variance of $X$ (assuming the omitted subscripts work in the usual way, which could be where the OP found a discrepancy between the two equations).
Working this out from the definition of covariance could be a worthwhile exercise to do once.
