+ 1

Why this code not gives expected output

var depth = parseInt(readLine(), 10); //your code goes here var days = 0; var dist = 0; while (dist <= depth) { dist +=7 if(dist<depth) dist -=2 days++ } console.log(days);

12th Dec 2023, 1:19 PM
SWAPNIL
SWAPNIL - avatar
2 ответов
+ 3
Why is it dist <= depth and not dist < depth?
12th Dec 2023, 1:40 PM
Paul
Paul - avatar
+ 2
What will happen if depth is 6?
12th Dec 2023, 2:18 PM
Wong Hei Ming
Wong Hei Ming - avatar