Pi is a reserved work, so I used pie. I haven’t seen this way of producing Pi 
before, and in both JavaScript and LivceCode it seems to be instantaneous. I 
think it’s a rewording of 4*(1-1/3+1/5-1/7+1/9…)

Anyway, see for yourself

on mouseup

put the ticks into t

put 1.0 into i

put 3.0 * 10^200 into x

put x into pie

repeat while (x > 0)

put x * i / ((i + 1.0) * 4.0) into x

add x / (i + 2.0) to pie

add 2.0 to i

end repeat

set numberformat to "x.xxxxxxxxxxxxxxxxxxxxxxx"

answer the ticks - t

answer (pie / (10.0 ^ 200))

end mouseup


BTW, I haven’t seen JavaScript using ‘let’ before, or having ’n’ to indicate a 
floating point number. That could be a dot net thing.


> On Oct 5, 2019, at 8:33 PM, Mark Wieder via use-livecode 
> <use-livecode@lists.runrev.com> wrote:
> 
> On 10/5/19 6:01 PM, Mark Wieder via use-livecode wrote:
>> On 10/5/19 4:57 PM, JB via use-livecode wrote:
>>> Hi Mark,
>>> I just visited the link Richard provided and it shows the following;
>> Hah! I missed a very important word in that sentence.
> 
> Nonetheless, here's pi in nine lines of javascript. I haven't tried 
> converting this yet... anyone wanna try writing this in LiveCode? And 
> benchmarking it?
> 
> <http://ajennings.net/blog/a-million-digits-of-pi-in-9-lines-of-javascript.html>

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to