• 性能速度


    <!DOCTYPE html>
    <html>
    <body>

    <script>
    document.write(multSilgarth3(99999999));
    function multSilgarth1(n) {
      var array = [];
      var result = 0;
      for (var i = 1; i < n; i ++) {
        if (i % 3 == 0 || i % 5 == 0) {
          array.push(i);
        }
      }
      for (var num of array) {
        result += num;
      }
      return result;
    }
    function multSilgarth2(n) {
      var array = [];
      for (var i = 1; i < n; i ++) {
        if (i % 3 == 0 || i % 5 == 0) {
          array.push(i);
        }
      }
      return array.reduce(function(prev, current) {
        return prev + current;
      });
    }
    function multSilgarth3(n) {
      var array = [];
      while (n >= 1) {
        n--;
        if (n%3==0||n%5==0) {
          array.push(n);
        }
      }
      return array.reduce(function(prev, current) {
        return prev + current;
      });
    }
    function multSilgarth4(n) {
      var sum = 0;
      while (n >= 1) {
        n--;
        if (n%3==0||n%5==0) {
          sum += n;
        }
      }
      return sum;
    }
    function multSilgarth5(n) {
      n = n-1;
      var sum = 0;
      for (n; n >= 1 ;n--) {
        (n%3==0||n%5==0) ? sum += n : null;
      }
      return sum;
    }
    function multSilgarth(N) {
      var threes = Math.floor(--N / 3);
    document.write(threes+ "<br>");
      var fives = Math.floor(N / 5);
    document.write(fives+ "<br>");
      var fifteen = Math.floor(N / 15);
    document.write(fifteen + "<br>");
      return (3 * threes * (threes + 1) + 5 * fives * (fives + 1) - 15 * fifteen * (fifteen + 1)) / 2;
    }
    </script>

    </body>
    </html>
    https://github.com/xitu/gold-miner/blob/master/TODO/what-i-learned-from-writing-six-functions-that-all-did-the-same-thing.md

  • 相关阅读:
    hadoop架构
    hdfs存储模型
    C语言编译过程
    linux文件类型和权限
    推荐系统效果评估
    推荐系统冷启动
    Js计算-当月每周有多少天
    3D动画
    固定边栏——淘宝滚动效果
    jquery图片轮播-插件
  • 原文地址:https://www.cnblogs.com/RadyGo/p/6074751.html
Copyright © 2020-2023  润新知