sumOfMultipleLine.js

    0

    0

    The code in this function reads a line of input from the user and stores the value of each integer in an array. It then calculates the sum of each integer using a loop that checks whether each number is evenly divisible by 3 and 5. The console logs the sum of the integers.

    function main() {
      var t = parseInt(readLine());
      for(var a0 = 0; a0 < t; a0++){
        var n = parseInt(readLine());
        var sum = 0;
        for(var i = 1; i < n; i++){
          if(i % 3 == 0 || i % 5 == 0){
            sum += i;
          }
        }
        console.log(sum);
      }
    
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.