Re: [R] How to create a warning inside the factorial function for decimal numbers

2020-06-01 Thread peter dalgaard
You might check that n %% 1 == 0. (Factorials do exist for fractional numbers -- check e.g. factorial(6.5). And please don't send HTML because, well, you can see the result below) - pd > On 1 Jun 2020, at 12:49 , Vahid Borji wrote: > > I am writing a code for the factorial function. My code

[R] How to create a warning inside the factorial function for decimal numbers

2020-06-01 Thread Vahid Borji
I am writing a code for the factorial function. My code is as follows: > f<- function(n){+ factorial <- 1+ if( n < 0 )+ print("Factorial of negative > numbers is not possible")+ else if( n == 0 )+ print("Factorial of 0 is 1")+ > else {+ for(i in 1:n)+ factorial <- factorial * i+