Number limit on division

Hello I am creating an app that calculates Pi(π) value. However, when I make a division it returns a number up to 6 digits. More details can be seen here:
calculate_example

There is a math block to show more digits, format as decimal

See the article in this FAQ for internal data types

It stills showing the same thing

Anyway I found how. Thanks ABG.

Here is the result Pi_Calculator.aia (4.0 KB)

1 Like

That's a thing of beauty!

Which series did you use?

(For the other board readers, here is the lazy reader version and video)


video:

Calculate Pi by code:

https://rosettacode.org/wiki/Pi

This looks like Nilakantha 15th century ...
image

1 Like

This is a good math challenge!

Yes, I used Nilakantha series
calculating-pi

@ABG I was wantering if there's a way to do this a bit more fast, cause it seems calculating very slow.

See Juan Antonio's Rosetta code link further back in this thread.
That site's samples use different algorithms that you can try to code in AI2.

But know that this is a game you can't win, but only enjoy along the way.

@Oakchris1955

Another way to write the Nilakantha code, it is also slow...

I will show my ignorance :wink: :

22/7?
:man_facepalming:

see I told you :wink:

Maybe 223/71 ?

Pi with JavaScript

borrar_pi_javascript.aia (2.2 KB)

http://ajennings.net/blog/a-million-digits-of-pi-in-9-lines-of-javascript.html

http://ajennings.net/pi.html

<!DOCTYPE html>
<html>
<head><meta charset="utf-8"></head><body>
<p id="demo"></p>
<script>
let i = 1n;
let x = 3n * (10n ** 1020n);
let pi = x;
while (x > 0) {
        x = x * i / ((i + 1n) * 4n);
        pi += x / (i + 2n);
        i += 2n;
}
window.AppInventor.setWebViewString("" +pi/(10n ** 20n)); // App Inventor
// document.getElementById("demo").innerHTML = pi/(10n ** 20n); // Web
</script>
</body></html>

I will use it. I am doing html

I am also planning to make a log for the output