| | |
Estimate value of e
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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 
Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds

Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
•
•
Join Date: Oct 2004
Posts: 29
Reputation:
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
C Syntax (Toggle Plain Text)
#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
Posts: 29
Reputation:
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.
![]() |
Similar Threads
- PC Price Estimate (GBP) (Motherboards, CPUs and RAM)
- Big-O estimate of complexity of merge sort (C++)
- Help with job estimate programs (C++)
- Estimate for a website and 3 domains (Website Reviews)
Other Threads in the C Forum
- Previous Thread: Need to make my program access a web page automatic when user opens program
- Next Thread: End of file function
| Thread Tools | Search this Thread |
adobe ansi api array arrays bash binarysearch centimeter char convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic fflush file floatingpointvalidation fork frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o ide inches infiniteloop initialization interest kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix meter microsoft motherboard multi mysql odf open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer pointers posix power probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling segmentationfault send shape single socketprograming socketprogramming stack standard strchr string strings structures suggestions systemcall test testautomation unix urboc user voidmain() wab win32api windows.h






