Fri, 11 Sep 1998 10:27:00 -0400


Actually, I think you want to use ceiling() instead of trunc(), as the latter
returns an integer too small to return all prime divisors, eg: factorize(6)
returns 1 2 6. But I was originally responding to Bill Venebles 'supplemental
exercise' to write a fn() that would return *all* of the divisors of an integer,
not just the prime ones.

Michael Bramley

______________________________ Reply Separator _________________________________
Subject: Re: Re[4]: [S] factors (divisors ) of an integer
Author: (INTERNET) at external
Date: 9/11/98 9:43 AM

How about doing most of the job with

factorize <- function(n)
p <- n/(w <- c(1:trunc(sqrt(n)),n))
w[trunc(p) == p]

Frank E Harrell Jr
Professor of Biostatistics and Statistics
Division of Biostatistics and Epidemiology
Department of Health Evaluation Sciences
University of Virginia School of Medicine
This message was distributed by To unsubscribe
send e-mail to with the BODY of the
message: unsubscribe s-news