How to write program 1- 1/3+1/4+1/5......n

 double a=4.0,sum=0.0; // take third term as "a"

int n=10;

 for(i=1 ;i<=n-2;i++)

{

sum=sum + 1/a;

a++

}

System.out.prtinln(1- 1.0/3+sum);

Comments

Post a Comment

Popular posts from this blog