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