[S] An improved factorize()

Frank E Harrell Jr (fharrell@virginia.edu)
Sat, 12 Sep 1998 22:34:05 -0400


Here is a modification of Michael Bramley's (bramley.m@pg.com) factorize
function with memory usage of approx. the square root of the original.

factorize <- function(n)
{
p <- n/(z <- 1:ceiling(sqrt(n)))
z <- z[trunc(p) == p]
unique(c(z, rev(n/z)))
}

---------------------------------------------------------------------------
Frank E Harrell Jr
Professor of Biostatistics and Statistics
Director, Division of Biostatistics and Epidemiology
Dept of Health Evaluation Sciences
University of Virginia School of Medicine
http://hesweb1.med.virginia.edu/biostatistics.html

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news