Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Logarithmus {
- public static void main(String[] args) {
- double ln2 = 0.0d;
- double counter = 1d;
- boolean check = false;
- for (double i = 1; i <= 1000000; i++) {
- if (i % 2 == 1) {
- ln2 -= 1d - (1 / i);
- } else {
- ln2 += 1d - (1 / i);
- }
- if ((ln2 - Math.log(2) <= 0.0023 && ln2 - Math.log(2) >= 0) ||
- (Math.log(2) - ln2 <= 0.0023 && Math.log(2) - ln2 >= 0)){
- check = true;
- counter++;
- }
- }
- System.out.println(counter);
- /*
- for (double j = ln2; j < Math.log(2); j++) {
- summanden++;
- System.out.println("Abweichung des Ergebnis vom echten Wert um " + summanden + " Stellen.");
- }
- /*if (Math.log(2) == ln2) {
- summanden++;
- System.out.println("Abweichung des Ergebnis vom echten Wert um " + summanden + " Stellen.");
- } */
- System.out.println("Mit der Formel ln2 = " + ln2);
- System.out.println("Probe: Math.log(2) = " + Math.log(2));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement