Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!
Hi there,I couldn't build the algorithm logic
View attachment 1886
Writing a factorial function is a nice beginner exercise, but not something you'd want to do here. That would be a lousy and wasteful algorithm.One suggestion is do the factorial first, if you succeed with that it's much easier then to implement the rest of it.
Nope. Just remember the last term, evaluate the next one, and add it to the sum.Wouldn't you still need to know the result of each factorial before you do x/x! ?
#define MAX 20 /* Or as far as you want to go */
float sum = 0, term = 1;
for ( int n = 1; n<=MAX; n++ )
{
term *= (x/n);
sum += term;
}
Code Forum is a community platform where coding enthusiasts can connect with other developers, engage in discussions, ask for help, and share their knowledge with a supportive community. It's a perfect place to improve your coding skills and to find a community of like-minded individuals who share your passion for coding.
We use essential cookies to make this site work, and optional cookies to enhance your experience.