[R] does a factorial function exist

Diego Kuonen Diego.Kuonen at epfl.ch
Thu Jun 24 08:34:25 CEST 1999


Alex Buerkle wrote:

> I've looked through the documentation with R-0.64.1 and have been unable
> to find a high-level function for evaluation of factorials (i.e., n!, not
> factorial designs).  Is there such a function?

This should do the trick:


fact<-function(numb)
  {
  if (numb==0) out<- 1
  if (numb<0) out<- 1
  if (numb>0) out<- prod(seq(numb))
  out
  }

:-)

  Diego Kuonen

--
------------------------------------------------------
Diego Kuonen
DMA - Ecublens, EPFL, 1015 Lausanne, Switzerland
Phone    :  + 41 (0)21 693 5508
Fax      :  + 41 (0)21 693 4250
E-mail   :  mailto:Diego.Kuonen at epfl.ch
Homepage :  http://statwww.epfl.ch/people/kuonen
------------------------------------------------------
  _                                                 _
 -o)     "Linux - Ready For 2000 By Nature !"      -o)
 /\\                                               /\\
_\_v             "Penguins DO fly !"              _\_v

------------------------------------------------------



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list