C++ Program

That uses factorial function for Eulers number

Page 1 of 1

2 Replies - 777 Views - Last Post: 23 April 2008 - 04:44 AM Rate Topic: -----

#1 srat  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 08-March 08

C++ Program

Post icon  Posted 22 April 2008 - 08:48 AM

I need help in developing a c++ program that uses the factorial function to compute an approximation of e(Euler` number). I should base my approximation on the following formula for e:
e=1+1/1! + 1/2! + 1/3! + 1/4! + 1/5! +.......+1/n
Is This A Good Question/Topic? 1

Replies To: C++ Program

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: C++ Program

Posted 22 April 2008 - 11:32 AM

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.
Was This Post Helpful? 0
  • +
  • -

#3 Virus Lover  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 16-April 08

Re: C++ Program

Posted 23 April 2008 - 04:44 AM

You Can Use Thsi Code To :


*********************
#include<iostream>
using namespace std;
int factorial(int);
void main()
{
cout<<"Enter N : "<<endl;
int n;
int sum=0;
for(int i=1;i<n;i++)
{
sum=sum+(1/factorial(i));
}
cout<<endl<<"Sum = "<<sum;
}
int factorial(int n)
{
int temp;

if(number <= 1) return 1;
temp = number * factorial(number - 1);
return temp;
}

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1