Opened 12 years ago

Closed 12 years ago

## #10374 closed defect (fixed)

# dojox.math.factorial incorrectly returning NaN for non-integers

Reported by: | Douglas Hays | Owned by: | Douglas Hays |
---|---|---|---|

Priority: | high | Milestone: | 1.5 |

Component: | Dojox | Version: | 1.4.0b |

Keywords: | Cc: | ||

Blocked By: | Blocking: |

### Description

dojox.math.factorial(1.5) returns NaN but should return

sqrt(pi)*3/4 ~= 1.329340388179137 as defined by the gamma function.

You can also verify this with the Windows calc.exe program (scientific view has the n! button).

### Attachments (1)

### Change History (3)

### comment:1 Changed 12 years ago by

### comment:2 Changed 12 years ago by

Resolution: | → fixed |
---|---|

Status: | new → closed |

**Note:**See TracTickets for help on using tickets.

Try not to overdo it: one can always complain that it doesn't work for negative and complex numbers, quaternions, and octonions too --- there are generalizations for these and other cases. ;-)

It reminds me of my robotics prof, who asked us to write a solver for a trivial quadratic polynomial, and embarrassed students by pointing out that their solution doesn't work for complex numbers, doesn't show that there are no solutions (

`a == 0, b == 0, c != 0`

), doesn't detect degenerated linear cases (`a == 0, b != 0`

, or`a != 0, b == 0`

), and in some cases any values are valid solutions (`a == 0, b == 0, c == 0`

).