Calculate log base e by recursion function.

This is a discussion on Calculate log base e by recursion function. within the C Programming forums, part of the General Programming Boards category; I have to calculate the value of e e=1+1/1!+1/2!+1/3!+1/4!+1/5!+1/6!+1/7!+1/8!........ I need to use recursion function. I can cal. the power ...

  1. #1
    Registered User alice's Avatar
    Join Date
    Mar 2004
    Posts
    36

    Calculate log base e by recursion function.

    I have to calculate the value of e

    e=1+1/1!+1/2!+1/3!+1/4!+1/5!+1/6!+1/7!+1/8!........

    I need to use recursion function.
    I can cal. the power of n(n!) but I dont have any idea on how to sum of them.

    Could someone give me hints on this. thk
    Code:
    #include<stdio.h>
    #include<math.h>
    
    double exp(double term){
    
    int n;
      if (term==0)
         return 1;
      if (term==1)
         return 1;
      else {
         n= term * exp (term-1);
         return  1/n + 1/(exp(n-1));
      }
    
    }
    
    int main(){
     float r;
    
      r=exp(7);
     printf("Result=%f",r);
      getchar();
    
    
    }
    Last edited by alice; 04-24-2004 at 04:16 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Right Triangle Program
    By BSmith4740 in forum C# Programming
    Replies: 9
    Last Post: 02-26-2008, 11:24 PM
  2. is there a log base 2 function?
    By qubit67 in forum C Programming
    Replies: 3
    Last Post: 05-02-2007, 01:08 AM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  4. log function causing an error
    By jbsloan in forum C Programming
    Replies: 2
    Last Post: 06-20-2004, 08:27 PM
  5. Recursion function won't exit
    By cheesehead in forum C++ Programming
    Replies: 20
    Last Post: 10-30-2001, 02:58 PM

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