0

pls how do i find the ans

The Snail in the Well The snail climbs up 7 feet each day and slips back 2 feet each night. How many days will it take the snail to get out of a well with the given depth? Sample Input: 31 Sample Output: 6 Explanation: Let's break down the distance the snail covers each day: Day 1: 7-2=5 Day 2: 5+7-2=10 Day 3: 10+7-2=15 Day 4: 15+7-2=20 Day 5: 20+7-2=25 Day 6: 25+7=32 So, on Day 6 the snail will reach 32 feet and get out of the well at day, without slipping back that night. this is my code function main() { var depth = parseInt(readLine(), 10); //your code goes here var a = depth/5 var b = depth%5 var c = b*0.1 var d = a - c console.log(d); } plssssss help me

25th Mar 2021, 7:21 PM
DURU SOMTOCHUKWU PHILIP
DURU SOMTOCHUKWU PHILIP - avatar
1 Antwort
0
* Read the problem and explanation of the example answer carefully * Write down the main steps you'll need as comments in your code before you start coding * I don't really see where you're going with the approach you've shown - especially var c, so I recommend starting again * You might want to try using a loop * This time please don't name your variables things like a, b, c etc. Give them meaningful names.
25th Mar 2021, 7:52 PM
CamelBeatsSnake
CamelBeatsSnake - avatar