Hello, there is a Bellara formula that should return the nth digit of pi in binary representation:
and there is my c # code:
while (true) { Console.WriteLine("Введите нужный разряд "); double n = Convert.ToInt32(Console.ReadLine()); double result = 0; double index = 0; do { result += (Math.Pow(-1, index) / Math.Pow(2, 10 * index)) * (-(Math.Pow(2, 5) / (4 * index + 1)) - 1 / (4 * index + 3) + (Math.Pow(2, 8) / (10 * index + 1)) - (Math.Pow(2, 6) / (10 * index + 3)) - (Math.Pow(2, 2) / (10 * index + 5)) - (Math.Pow(2, 2) / (10 * index + 7)) + 1 / (10 * index + 9) ); ++index; } while (index < n); Console.WriteLine((1.0 / Math.Pow(2, 6)) * result); } returning this:
Please tell me the error


Math.PI, up to the last sign of the constant, and not Pi itself, of course. About the method of calculating the necessary bits better read the author bellard.org/pi/pi_n2/pi_n2.html - rdorn