title: Factorial in XSLT limit?
body: <p>I have the following factorial function implemented in XSLT:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
      &lt;xsl:output method="text"/&gt;
      &lt;xsl:template match="/"&gt;
          &lt;xsl:apply-templates&gt;
          &lt;/xsl:apply-templates&gt;
      &lt;/xsl:template&gt;
  
      &lt;xsl:template match="factorial" name="factorial"&gt;
          &lt;xsl:param name="n" select="@n" /&gt;
          &lt;xsl:param name="f" select="1" /&gt;
          &lt;xsl:if test="$n &amp;gt; 1"&gt;
              &lt;xsl:call-template name="factorial"&gt;
                  &lt;xsl:with-param name="n"&gt;
                      &lt;xsl:value-of select="$n - 1" /&gt;
                  &lt;/xsl:with-param&gt;
                  &lt;xsl:with-param name="f"&gt;
                      &lt;xsl:value-of select="$f * $n" /&gt;
                  &lt;/xsl:with-param&gt;
              &lt;/xsl:call-template&gt;
          &lt;/xsl:if&gt;
          &lt;xsl:if test="$n = 1"&gt;
              &lt;xsl:value-of select="$f" /&gt;
          &lt;/xsl:if&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>In both Firefox and IE7, <code>170!</code> works fine but <code>171!</code> only returns <code>NaN</code>.  Is this a well-defined limit in XSLT/XPath math, or is there a way of getting even higher values of <code>n!</code> ?</p>