...and a challenge
Jerry Jensen
jerry at jhjensen.com
Sat Oct 5 23:57:16 EDT 2019
Does it give the correct answer for pie? I don’t think the n suffix is for floating point. I thought it was for expressing bigint type.
> On Oct 5, 2019, at 8:34 PM, Colin Holgate via use-livecode <use-livecode at lists.runrev.com> wrote:
>
>
> 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 at 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>
More information about the use-livecode
mailing list