f[x_]:= Exp[
        Sin[x]]

Simpson[n_, a_, 
        b_] := (
NN = 
          2  n; 
h  =  (b - a)/
            NN; 
oddsum = 0; 
evensum = 
          0; 
For[i = 0,  i ≤ n - 1, 
          i = i + 1, 
oddsum  =  
            oddsum  +  
              f[a  +  (2  i + 1) 
                    h]; 
evensum  =   evensum  +  
              f[a + 2  i h]]; 
S =  
          h/3 ( 4 oddsum  +  2  evensum  -  f[a] + 
                f[b]))

N[Simpson[15, 0,  2  Pi]]

N[S]

Integrate[f[x], {x, 0, 2  Pi}]

N[%]

f[x_] :=  Sin[Exp[x]]

N[Simpson[5, 2, 4]]

Integrate[f[x], {x, 2, 4}]

N[%]

NIntegrate[f[x], {x, 2, 4}]

N[Simpson[100, 2, 4]]