Advertisement
andruhovski

Demo 01 Java

Feb 16th, 2019
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. public class HelloWorld{
  2.  
  3.      public static void main(String []args){
  4.        
  5.         double result=1;
  6.         double sign = -1;
  7.         int n=100000;
  8.         for(int i=2;i<=n;i++)
  9.         {
  10.             result=result+sign/i;
  11.             sign=-sign;
  12.         }
  13.        
  14.         System.out.println("Calculated value of natural logarithm of 2 is "+ result);
  15.         System.out.println("System function value of natural logarithm value of 2 is: "+Math.log(2));
  16.      }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement