<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 9.00.8112.16470"></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=076072018-09042013><FONT color=#0000ff
size=2 face="Courier New">Would it be possible to use <A
title="Stirling's approximation"
href="http://en.wikipedia.org/wiki/Stirling%27s_approximation"><FONT size=3
face="Times New Roman">Stirling's approximation</FONT></A> for a
fast inexact first approximation for factorials of very big numbers
and from there quickly get to an exact factorial? (if exactness is required) I
don't know for I haven't thought thoroughly about this.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=076072018-09042013><FONT color=#0000ff
size=2 face="Courier New">Jos.</FONT></SPAN></DIV><BR>
<BLOCKQUOTE
style="BORDER-LEFT: #0000ff 2px solid; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"
dir=ltr>
<DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left>
<HR tabIndex=-1>
<DIV></DIV><STRONG><FONT size=2 face=Tahoma></FONT></STRONG><BR></DIV>
<DIV dir=ltr>
<DIV class=gmail_extra>
<DIV class=gmail_quote>On Tue, Apr 9, 2013 at 2:42 PM, Matthew Flatt <SPAN
dir=ltr><<A href="mailto:mflatt@cs.utah.edu"
target=_blank>mflatt@cs.utah.edu</A>></SPAN> wrote:<BR>
<BLOCKQUOTE
style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote> (for/product ([p (in-range (+ m 1) (+ n 1))])
p)</BLOCKQUOTE></DIV><BR><BR></DIV>
<DIV class=gmail_extra>This fact/for variant is a clear winner:<BR>> (time
(void (fact/for 1000000)))<BR>cpu time: 6948 real time: 6956 gc time:
964<BR>> (time (void (factorial 1000000)))<BR>cpu time: 9936 real time:
9951 gc time: 3700<BR>> (time (void (fact 1000000)))<BR>cpu time: 8445 real
time: 8460 gc time: 2273<BR><BR></DIV>
<DIV class=gmail_extra>But I don't fully understand why a simple (for/product
([p (in-range 1 (add1 n))]) p) is as fast as the iota variants.<BR></DIV>
<DIV class=gmail_extra>I see that the latter makes many more small products,
which are certainly faster, but it also does more products of 2 big numbers,
whereas for/product makes only big*small products. Is that a sufficient
reason?<BR><BR></DIV>
<DIV class=gmail_extra>Laurent<BR></DIV>
<DIV class=gmail_extra><BR></DIV></DIV></BLOCKQUOTE></BODY></HTML>