Home Page for the TeradataForum
 
 

 

Archives of the TeradataForum





Message Posted: Wed, 21 Sep 2005 @ 13:58:29 GMT





     
  <Prev Next>   <<First <Prev Next> Last>>  




Subj:   Re: Factorial in Teradata
 
From:   jmfelts



If you are calculating small factorial's, multiplication is fine. However, if calculating large numbers, this can become difficult as the numbers get large quickly. If an approximation is fine (albeit a pretty good approximation as the numbers get fairly large), then you can use Stirling's Approximation

www.en.wikipedia.org/wiki/Stirling%27s_approximation

Basically:

     n! ~= sqrt(2*pi*n)*[(n/e)^n]

     where pi ~ 3.14159...
     and e ~ 2.718282

Dunno if this helps, but as a previous poster pointed out, for n>13, integers can't be used, and it doesn't take long until DECIMAL can't be used either (so FLOAT must be chosen to keep it in number format).





     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
 
  Top Home Join Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky 
Last Modified: 30 Jun 2008