Thread: Looping question

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    1

    Looping question

    Looking to find out how to write a program in C to calcilate Eulars number. The following formula is used for the e=1+1/1!+1/2!+1/3!+1/4!+1/5!+1/6!...+1/(n-1)!+1/n!.

    The program needs to approximate e using a loop that terminates when the difference between 2 consecutive numbers differs by less than .0000001.

    I have been working on this for a while and just need some pointers.

    Thanks,
    Sparky

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    So post some code then, and lets see where you've got to
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The program needs to approximate e using a loop that terminates when the difference between 2 consecutive numbers differs by less than .0000001
    Hate to break it to ya, but you're screwed. Floating point numbers tend to not be that great for precision.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  2. Not the normal looping question...
    By JKI in forum C++ Programming
    Replies: 12
    Last Post: 10-18-2003, 06:02 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. Question about linked lists.
    By cheeisme123 in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2003, 01:36 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM