Project Euler #1: Multiples of 3 and 5

  • + 0 comments

    It runs well but when I try sending code, it times out in test 2 and 3.

        var t = parseInt(readLine());
        for(var a0 = 0; a0 < t; a0++){
            var qtt3 = 0, qtt5 = 0, rep = 0;
            var n = parseInt(readLine());
            for(var i=1; i<n; i++){
                if(i%3===0) qtt3 += i
                if(i%5===0) qtt5 += i
                if(i%3===0 && i%5===0) rep += i
            }
            console.log(qtt3 + qtt5 - rep)
        }