Even the straightforward factorial function required a fixed number of steps which is O(n!). Caching previous results is a significant optimization, but it would mean being able to store say n! for all n < 321. Then compute n! as n * (n-1)!. But even then it is asymptotically the same running time. Approximation is usually not acceptable for something as basic as this. There are other better factorial algorithms based on prime factorizations which run in exponential time, which is much better.
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---