THE SNAIL IN THE WELL
Hello everyone, I am completing the javascript course, however in the second module they pose the following problem, which I have been trying to solve since yesterday, if someone could guide me I would appreciate it very much. Pd: I do not speak English, I am using a translator due to the demand of American users The snail climbs 7 feet each day and retreats 2 feet each night. How many days will it take for the snail to get out of a well with the given depth? Input example: 31 Output example: 6 Explanation: Let's break down the distance that 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 come out of the well during the day, without slipping again that night.