Hallo, Ich habe ein Programm erstellt das mit Pi errechnet. Leider hat mein verwendetes Double nicht genug Nachkommastellen. Bitte um Lösung/Lösungsvorschlag
Java:
public class pi
{
public static void main(String[] args) {
double pi_zw = 0;
double pi;
int n;
for (n=1;n <= 1000000000; n++) {
pi_zw = pi_zw + 1 / Math.pow(n, 2);
if ((n % 1000) == 0) {
pi = Math.sqrt(pi_zw * 6);
System.out.println(pi);
}
}
}
}
Zuletzt bearbeitet von einem Moderator: