talha-devp / Approximating-the-Pi

Approximating the Pi with randomly sent particles.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Approximating-the-Pi

Tested a logic I saw from The Coding Train.

To simplify if you send random particles to a square and if you draw a circle inside of it, the particles that's inside of the circle's division by all particles multiplied by 4 will give us the pi.

Formula Explained:

(pi * r ^ 2) / (4 * r ^ 2) = pi/4 = insideCircleAmount / allParticles then we reach:
pi = 4 * insideCircleAmount / allParticles

About

Approximating the Pi with randomly sent particles.

License:MIT License


Languages

Language:C++ 100.0%