A frog is at the bottom of a 30 metre well. Each day it climbs 5 metres up the side, but it then slips back 3 metres each night. How long does it take to reach the top of the well?
Is there an easier /more direct way to make an alternating sum than this?
y = 14; Flatten[Transpose[{Table[2 x + 5, {x, 0, y - 1}],
Table[2 x, {x, 1, y}]}]]
Update
Not automated, but simple and more direct than first attempt:
Accumulate[Table[If[OddQ[n], 5, -3], {n, 1, 27}]]

Array[2-2(-1)^#+#&,27]is the way to go... – ciao Mar 23 '14 at 23:59(well depth / meters climbed) / (meters climbed - meters slipped)rounded up and added one:Ceiling[(30 - 5)/(5 - 3)] + 1. – A little mouse on the pampas Nov 17 '20 at 07:18