andruhovski icon

Demo 01 Java

andruhovski | PRO | 02/16/19 11:56:00 AM UTC | 0 ⭐ | 615 👁️ | Never ⏰ | []
Java |

470 B

|

None

|

0 👍

/

0 👎

public class HelloWorld{
 
     public static void main(String []args){
        
        double result=1;
        double sign = -1;
        int n=100000;
        for(int i=2;i<=n;i++)
        {
            result=result+sign/i;
            sign=-sign;
        }
        
        System.out.println("Calculated value of natural logarithm of 2 is "+ result);
        System.out.println("System function value of natural logarithm value of 2 is: "+Math.log(2));
     }
}

Comments