Dear Gordon,
Try also,

> unique(apply(expand.grid(commfac,commfac),1,prod))
[1]  1  2  5  4 10 25

HTH,

Jorge


On Mon, Feb 23, 2009 at 9:52 PM, Fox, Gordon <gfox@cas.usf.edu> wrote:

> This is a seemingly simple problem - hopefully someone can help.
> Problem: we have two integers. We want (1) all the common factors, and
> (2) all the possible products of these factors. We know how to get (1),
> but can't figure out a general way to get (2).
>
>
>
> Example: 40 and 80 have these factors: c(1,2,2,2,5) and c(1,2,2,2,2,5).
> We can use match() to get the common factors c(1,2,2,2,5). What we want
> to be able to get from this is the list of all the possible products,
> which should be the concatenation of the original list, the products of
> all the pairs, of all the triplets, and so forth:
> c(1,2,2,2,5,4,8,10,20,40).
>
>
>
> The application is this: we have an area that is, say, 40 x 80 units. We
> want to find all the possible grids (of square integer-valued units)
> that can be placed over that area that cover it completely. The list at
> the end of the preceding paragraph is the right answer - the question is
> how to get it from our list of common factors, other than by brute
> force.
>
>
>
> Thanks for any advice.
>
>
>
> Gordon
>
>
>
> --
>
> Dr. Gordon A. Fox       Voice: (813)974-7352       Fax: (813)974-3263
> Dept. of Integrative Biology ((for US mail:)SCA 110) ((for FedEx
> etc:)NES 107)
> Univ. of South Florida                 4202 E. Fowler Ave.
> Tampa, FL 33620, USA                   http://foxlab.cas.usf.edu
>
> "All the fun of sitting still, being quiet, writing down numbers. Yes,
> science has it all." -- Principal Skinner
>
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]


