Given the Newton-Cotes formula for 4 points, can I do an integration over an interval where there are arbitrary many points (at least 4 points) given (so e.g. 4,5,6,7,...)? To be concrete, I have the Newton-Cotes formula
$\int_a^b f(x)dx = h[\frac{3}{8}f_0 + \frac{9}{8}f_1 + \frac{9}{8}f_2 + \frac{3}{8}f_3]$
which gives me an approximation of the integral over the interval $[a,b]$, for 4 given function values $f_i=f(x_i), \quad i=0...3$. How we get to these weights is clear (integration of Lagrange basis polynomials).
Now I have some code snippet where one applies the 4-point Newton-Cotes formula to an interval where we have 5 given function values:
$\int_a^b f(x)dx = h[\frac{8}{24}f_0 + \frac{32}{24}f_1 + \frac{16}{24}f_2 + \frac{32}{24}f_3 + \frac{8}{24}f_4]$,
How can we arrive at the weights used for calculation of this integral?
PS: In the code there are more weights given, also for the 4-point formula applied to 6 points and 7+ points in the interval $[a,b]$, but an explanation for the case of 5 points should be enough for understanding.