Sum =x-x3/3! + x5/5! – x7/7! +……. Stop when the term<0.0001.
very quick please.
Algorithm
factorial(n){ //factorial method
if(n==1)
return 1;
return n*factorial(n-1);
}
-----------------------------------
start
Read Sum=0, i=1, term,d,x=2;
while(true){
term=pow(x,i)/factorial(i);
d=round(term*100000)/100000;
if(d<0.0001)
break;
if(i%2==0)
Sum=Sum+d;
else
Sum=Sum-d;
i+=2;
}
print(Sum);
stop
Get Answers For Free
Most questions answered within 1 hours.