Thread: Euler's Number

  1. #16
    Registered User
    Join Date
    Jun 2007
    Posts
    61

    Cool

    The thing is what I typed is what he gave us to use. Supposed to make a function out of it? I thought all along it did not make any sense. Is it possible to start all over and how would I start declaring a function to calculate the Euler's number?

  2. #17
    Registered User
    Join Date
    Jul 2006
    Posts
    162
    Code:
    double fa (double x)
    {
    	double tmp1=0, tmp2=0;
    	for (int j=1; j<=x; ++j)
    	{
    		tmp1 = 1.0;
    		for (int i=1; i<j; ++i)
    		{
    			tmp1 *= i;
    		}
    		tmp2 += 1.0 / double(tmp1);
    	}
    	return tmp2;
    }
    I gave it a go with some random number -- fa (13.0) -> output: 2.71828
    Last edited by simpleid; 06-12-2007 at 10:06 AM.

  3. #18
    Registered User
    Join Date
    Jun 2007
    Posts
    61
    Thanks for telling me about removing the return it worked YEAH

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. scanf oddities
    By robwhit in forum C Programming
    Replies: 5
    Last Post: 09-22-2007, 01:03 AM
  2. Calculating next prime number
    By anilemon in forum C Programming
    Replies: 8
    Last Post: 04-17-2006, 10:38 AM
  3. Prime number program problem
    By Guti14 in forum C Programming
    Replies: 11
    Last Post: 08-06-2004, 04:25 AM
  4. parsing a number
    By juancardenas in forum C Programming
    Replies: 1
    Last Post: 02-19-2003, 01:10 PM
  5. Random Number problem in number guessing game...
    By -leech- in forum Windows Programming
    Replies: 8
    Last Post: 01-15-2002, 05:00 PM