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 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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

Depth of well = 32feet

5th Apr 2021, 1:16 PM
Abdulqadir Jimoh
Abdulqadir Jimoh - avatar
2 Answers
+ 2
nDays = 0 hight = 2 while hight< depth: hight -=2 nDays += 1 hight +=5 print(nDays)
5th Apr 2021, 1:23 PM
Mohamad Kamar
Mohamad Kamar - avatar
0
With just one if statment : if (depth%5<3){ var days=depth/5; }else{ var days=(depth/5)+1; } console.log(parseInt(days));
4th Dec 2021, 6:14 AM
Murtada abed
Murtada abed - avatar