how to write a program for a0/n!+a1x/(n-1)!+a2x^2/(n-2)!....a^nx^n?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gowthami naga
    New Member
    • Nov 2013
    • 1

    #1

    how to write a program for a0/n!+a1x/(n-1)!+a2x^2/(n-2)!....a^nx^n?

    program for sum of factorail....
    a0/n!+a1x/(n-1)!+a2x^2/(n-2)!....a^nx^n?
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Use a for loop, for each loop iteration calculated the value of the current term and then add the result to a variable that was initialised before the loop started. At the end of the loop the variable will contain your result, assuming that the maths remained with-in the bounds of the platform.

    Comment

    • stdq
      New Member
      • Apr 2013
      • 94

      #3
      It might be a good idea to use a function that calculates the factorial of a given non-negative integer n (n!).

      Comment

      • donbock
        Recognized Expert Top Contributor
        • Mar 2008
        • 2427

        #4
        Be careful, n doesn't have to be very large before n! is too large to fit in the standard C integral types.
        • 9! > minimum value of USHRT_MAX
        • 9! > minimum value of UINT_MAX
        • 13! > minimum value of ULONG_MAX
        • 21! > minimum value of ULLONG_MAX

        Comment

        Working...