0
(Solved)I wonder, the answers sum = 9 if depth =42, how about you guys?
function main() { var depth = parseInt(readLine(), 10); //your code goes here sum = 0 j = 0 for(i=0; j < depth; i++){ j = j+5 sum += 1 } console.log(sum) }
2 odpowiedzi
+ 2
Variable <i> is not necessary here, so we can safely remove it. Maybe this snippet can explain where <sum> got its value.
function main()
{
var depth = 42;
var sum = 0;
for (var j = 0; j < depth; j += 5)
{
console.log(j);
sum += 1;
}
console.log(sum);
}
+ 1
I see, thank you 🙏🙏🙏. So, var i adds extra number 😇