+ 1
How to print the sum of series= x/1-x/2+x/3-x/4.....n
plz tell tomorrow is my exam
10 Respuestas
+ 21
it can be written as x(1- 1/2 + 1/3 - 1/4 + 1/5 ...)
so U just need to run a loop for accounting that & then multiply that with x in last
double prdct=0;
for (int a=1;a =<n;a++) prdct+=prdct/a;
System.out.println(prdct*x);
👉here , I have taken prdct in double bcz int/int is always an integer in java
//btw can be done directly using math
+ 1
please check this
https://code.sololearn.com/czMn4GHSU4lQ/?ref=app
0
https://code.sololearn.com/Wu6sPJIYW4ma/?ref=app
something like this?
0
no brother just simple java language with for loop . I'm in 10th standard
0
sorry but i dont understand you
0
like this:
int i,s=0;
for(i=1;1<=n;1++)
{
sum=sum+...
this was just for demo
hope u understood the concept. Plz help
0
try sum+= sum
0
sorry but im very bad at java
0
or sum++