Euler's Number

This is a discussion on Euler's Number within the C++ Programming forums, part of the General Programming Boards category; The thing is what I typed is what he gave us to use. Supposed to make a function out of ...

  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 11:06 AM.

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

Page 2 of 2 FirstFirst 12
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, 02:03 AM
  2. Calculating next prime number
    By anilemon in forum C Programming
    Replies: 8
    Last Post: 04-17-2006, 11:38 AM
  3. Prime number program problem
    By Guti14 in forum C Programming
    Replies: 11
    Last Post: 08-06-2004, 05: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21