Write a c++ program to sum the sequence
1+ 1/1! + 1/2! + 1/3! + .......
1
Expert's answer
2011-10-07T09:25:05-0400
#include <iostream> using namespace std; void main(){ double s = 0;& //that is the sum double factorial = 1;& //it's the denominator int i = 1; cout<<"factorial = "<<factorial<<"\r\n"; for (i=1;i<=10;i++) {& //10 cycles is enough, we'll get 1.71828 at the eighth step factorial = i*factorial; s = s + 1/factorial; cout<<"s = "<<s<<"\r\n"; } }
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment