title: function return NaN
body: <p>I dont understand why the below function return NaN even the answer shouldn't be NaN.
  I have tried to search similar question but most of them in other programming language that i couldn't understand.</p>
  
  <p>Code: </p>
  
  <pre><code>a0 = 1.5; a1 = 0.4; b1 = 0.3; g1= 0.7
  nu = rep(0,1)
  h.new = rep(0,1)
  ddp = rep(0,1)
  
  nu[1]=0
  
  h.new[1] = a0/(1-a1-b1)
  ddp[1] = 0.5*log(g1)- g1*h.new[1] + 
    nu[1]*(log(nu[1])-1) - log(factorial(nu[1]))+(g1)*nu[1]* 
    (1+log(h.new[1]/nu[1]))
  </code></pre>
  
  <p>This is the output:</p>
  
  <pre><code>###&gt; ddp
  ###[1] NaN
  </code></pre>
  
  <p>Then I do manual calculation, clearly show that ddp is not NaN:</p>
  
  <pre><code>###h.new = 1.5/(1-0.4-0.3) = 5
  
  ###ddp 
  ###= 0.5*log(0.7)- (0.7)*(5) + 
  ###(0)*(log(0)-1) - log(0!)+(0.7)*(0)* 
  ###(1+log(5/0))
  
  ###= 0.5*log(0.7)- (0.7)*(5)
  
  ###= -3.6783
  </code></pre>
  
  <p>I did know for sum() function, na.rm=TRUE could ommit all the missing value,
  but in this case, how to modify the code to make it return to the correct answer?</p>
  
  <p>Thanks in advance.</p>