On 10/14/11 2:39 AM, Nataraj S Narayan wrote:
> Good candidate for recursive algorithm i think.
At first glance maybe, but it is actually a horrible candidate. That is
due to the fact that the number of values is unknown and recursion has a
built-in limit based on the stack size. So if your logic is recursive it
will work one day on one file of numbers and not the next on a longer file.

Much better to simply maintain a summed value, read a value, add it to
the sum, write the current sum, and continue until done.

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to