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