0
Can anyone tell me Why this doesn't work for the snail in the well task?
2 Réponses
+ 1
function main() {
var depth = parseInt(readLine(), 10);
//your code goes here
let distance = 0;
let days = 0;
do {
distance += 7;
days++;
if(distance >= depth){
break;
}
distance -= 2;
}
while(distance < depth );
console.log(days);
}
0
A simple one line of code should solve the problem:
Console.log(Math.round(depth / 5);