•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 375,199 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,065 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:
Views: 3598 | Replies: 20
![]() |
•
•
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,873
Reputation:
Rep Power: 32
Solved Threads: 108
Hmm ... start by writing a recurisve function to find the factorial of a number. There's a tutorial on recursion in either the C++ or the Computer Science section of this site - I forget which. You should also be able to find this function by doing a quick google search. Then just add 1/ to your factorial equation and it should do the trick
Dani the Computer Science Gal
Do you run a computer-related website? Feature it in our niche link directory!
Do you run a computer-related website? Feature it in our niche link directory!
•
•
Join Date: Oct 2004
Location: Austria
Posts: 29
Reputation:
Rep Power: 4
Solved Threads: 0
I know that I'm breaking the rule not to make anybody's homwork.
But since the answer is so simple I can not help it to post a solution
K.
But since the answer is so simple I can not help it to post a solution
#include <iostream>
double fakt(int i)
{
if ( i == 1 )
return 1.0;
return fakt( i -1 ) * i;
}
int main() {
double e = 1.0;
for ( int i = 1; i < 4000; i++ ) {
e += 1.0 / fakt(i);
}
std::cout << " e = " << e << std::endl;
return 0;
}•
•
Join Date: Oct 2004
Location: Austria
Posts: 29
Reputation:
Rep Power: 4
Solved Threads: 0
•
•
•
•
Originally Posted by Narue
>but with my compiler the result is still correct
That's nice, but your code is still wrong even if the compiler that you use happens to interpret "undefined" as something intelligent.
K.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
Similar Threads
- Help with job estimate programs (C++)
- Estimate for a website and 3 domains (Website Reviews)
- high school student needs help!!! please help!! (Website Reviews)
- Domain Appraisal Kit (Domain Names for Sale)
- I want google to index forum threads (Search Engine Optimization)
- Need server for office (Networking Hardware Configuration)
- Help: Weird Hard drive space flucuation? (Windows NT / 2000 / XP / 2003)
Other Threads in the C Forum
- Previous Thread: Need to make my program access a web page automatic when user opens program
- Next Thread: c language problm, how to pass pointer to a function



Linear Mode