Skip to content

Instantly share code, notes, and snippets.

@Ragnok123

Ragnok123/Main.java

Created Dec 24, 2019
Embed
What would you like to do?
PI
import java.util.*;
import java.lang.*;
import java.io.*;
class Main{
public static double PI = 3; //it is aproximally value
public static void main (String[] args) throws java.lang.Exception{
int n = 2;
for (int i = 0; i < 500; i++) {
PI += (i % 2 == 0 ? 1 : -1) * 4.0 / (n * (n + 1) * (n + 2));
n += 2;
}
System.out.println(PI); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment