Ad
Code
Diff
  • const tab = (func, start, end, step) => {
      let sum = 0;
      const count = Math.ceil((end - start) / step) + 1;
      for (let i = 0; i < count; i++) {
        sum += func(start + i * step);
      }
      return sum;
    }
    • const tab = (f, a, b, h) => {
    • return Array.from(
    • {
    • length: Math.ceil((b - a) / h) + 1
    • },
    • (v, i) => f(a + (i * h))).reduce((a, c) => a += c, 0
    • )
    • }
    • const tab = (func, start, end, step) => {
    • let sum = 0;
    • const count = Math.ceil((end - start) / step) + 1;
    • for (let i = 0; i < count; i++) {
    • sum += func(start + i * step);
    • }
    • return sum;
    • }