Guest User

Untitled

a guest
May 26th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. wart ich schicks dir gleich ma
  2. meine Lösung: die Falsch ist
  3. // TODO code application logic here
  4.  
  5. double LnDrittel = 0;
  6. double vorzeichen = -1;
  7. double zaehler = 1;
  8. double nenner = 1;
  9. double bruch = 0;
  10. double ergebnis = 0;
  11.  
  12. for (int i = 1; i <= 1000; i++){
  13. nenner = i;
  14. vorzeichen *= -1;
  15. bruch = (zaehler/nenner)* vorzeichen;
  16.  
  17. LnDrittel = LnDrittel += bruch;
  18. }
  19.  
  20. System.out.println("Ln(3) = " + LnDrittel);
  21. richtige Lösung:
  22. double vorzeichen = -1;
  23. double LnDrittel = 0;
  24. double zaehler = 1;
  25. double nenner = 1;
  26. double bruch = 0;
  27.  
  28. for (int i = 1; i < 1000000000; i++){
  29. nenner+= nenner;
  30. vorzeichen *= (-1);
  31. bruch = vorzeichen *(1-zaehler/nenner);
  32. LnDrittel+= bruch;
  33. }
  34.  
  35. System.out.println("Ln(3) = " + LnDrittel);
Add Comment
Please, Sign In to add comment