*X-seq*: zsh-users 26588*From*: Lawrence Velázquez <vq@xxxxxxxxx>*To*: Ray Andrews <rayandrews@xxxxxxxxxxx>*Cc*: zsh-users@xxxxxxx*Subject*: Re: run time of math problem*Date*: Fri, 19 Mar 2021 23:59:37 -0400*Archived-at*: <https://zsh.org/users/26588>*Archived-at*: <http://www.zsh.org/sympa/arcsearch_id/zsh-users/2021-03/5F4EC7FA-639D-42A9-BCB6-C0477F675509%40larryv.me>*In-reply-to*: <499ede49-ed95-005e-90d0-6c3265f4cea4@eastlink.ca>*List-id*: <zsh-users.zsh.org>*References*: <a1c6d13a-7a04-fba4-4419-7eccbf013824@eastlink.ca> <41359-1616197959.973399@0dqq.OWmi.jXTb> <499ede49-ed95-005e-90d0-6c3265f4cea4@eastlink.ca>

> On Mar 19, 2021, at 10:40 PM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote: > > As to the rest I was just stupidly forgetting that I'm in a loop. > I'm faking a summation. We don't have summation do we? Not that I'm aware of, but you're computing partial sums of geometric series [*], so you have a closed-form expression available to you: for (( level = 1; level < 100; level++ )); do (( remainder = (level - 1.0) / level, sum = level - level * remainder**level, divided = sum * (1.0 / level) )) echo for level: $level, survival: $divided done [*]: https://mathworld.wolfram.com/GeometricSeries.html -- vq

**References**:**run time of math problem***From:*Ray Andrews

**Re: run time of math problem***From:*Oliver Kiddle

**Re: run time of math problem***From:*Ray Andrews

Messages sorted by: Reverse Date, Date, Thread, Author