Re: Divisors

*To*: mathgroup at smc.vnet.net*Subject*: [mg24295] Re: [mg24272] Divisors*From*: Arnold <arnoldk at gauss.cam.wits.ac.za>*Date*: Fri, 7 Jul 2000 00:11:35 -0400 (EDT)*References*: <200007060310.XAA26697@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hi, here's one approach to getting divisors from the known factorization list: divisors[lst_] := Times @@@ Flatten[ Outer[List, Sequence @@ (#[[1]]^Range[0, #[[2]]] & /@ lst)], Length[lst] - 1] lst = FactorInteger[7!] Out[1]= {{2, 4}, {3, 2}, {5, 1}, {7, 1}} divisors[lst] Out[2]= {1, 7, 5, 35, 3, 21, 15, 105, 9, 63, 45, 315, 2, 14, 10, 70, 6, 42, 30, 210, \ 18, 126, 90, 630, 4, 28, 20, 140, 12, 84, 60, 420, 36, 252, 180, 1260, 8, 56, \ 40, 280, 24, 168, 120, 840, 72, 504, 360, 2520, 16, 112, 80, 560, 48, 336, \ 240, 1680, 144, 1008, 720, 5040} Sort[%] == Divisors[7!] Out[3]= True Cheers, Arnold Knopfmacher University of the Witwatersrand South Africa Hans Havermann wrote: > I need a re-formulated "divisors" function that works, *not* on > Integers, but on the *list of factors* that one gets when one applies > FactorInteger to a number. That way I can still get the divisors of a > number whose factorization is difficult, but nonetheless known. > > I have a rough working model of such a function but it relies on the > function Subsets found in DiscreteMath`Combinatorica` (see below) and I > don't have enough RAM to apply Subsets to lists larger than 20 elements. > Unfortunately, I need to find the divisors of numbers whose > factorization comprises as many as 40 elements. > > Can anyone provide a programming solution? > > -- > << DiscreteMath`Combinatorica` > > fac = First[Transpose[FactorInteger[2*3*3*11*11*11*13]]]; > pow = Last[Transpose[FactorInteger[2*3*3*11*11*11*13]]]; > expfac = {}; Do[ > Do[expfac = Append[expfac, fac[[i]]], {j, 1, pow[[i]]}], {i, 1, > Length[pow]}]; expfac > > {2, 3, 3, 11, 11, 11, 13} > > div = ReplacePart[Union[Subsets[expfac]], {1}, 1] > > {{1}, {2}, {3}, {11}, {13}, {2, 3}, {2, 11}, {2, 13}, {3, 3}, {3, 11}, > {3, 13}, {11, 11}, {11, 13}, {2, 3, 3}, {2, 3, 11}, {2, 3, 13}, {2, 11, > 11}, {2, 11, 13}, {3, 3, 11}, {3, 3, 13}, {3, 11, 11}, {3, 11, 13}, {11, > 11, 11}, {11, 11, 13}, {2, 3, 3, 11}, {2, 3, 3, 13}, {2, 3, 11, 11}, {2, > 3, 11, 13}, {2, 11, 11, 11}, {2, 11, 11, 13}, {3, 3, 11, 11}, {3, 3, 11, > 13}, {3, 11, 11, 11}, {3, 11, 11, 13}, {11, 11, 11, 13}, {2, 3, 3, 11, > 11}, {2, 3, 3, 11, 13}, {2, 3, 11, 11, 11}, {2, 3, 11, 11, 13}, {2, 11, > 11, 11, 13}, {3, 3, 11, 11, 11}, {3, 3, 11, 11, 13}, {3, 11, 11, 11, > 13}, {2, 3, 3, 11, 11, 11}, {2, 3, 3, 11, 11, 13}, {2, 3, 11, 11, 11, > 13}, {3, 3, 11, 11, 11, 13}, {2, 3, 3, 11, 11, 11, 13}} > > Sort[Table[Apply[Times, div[[i]]], {i, 1, Length[div]}]] > > {1, 2, 3, 6, 9, 11, 13, 18, 22, 26, 33, 39, 66, 78, 99, 117, 121, 143, > 198, 234, 242, 286, 363, 429, 726, 858, 1089, 1287, 1331, 1573, 2178, > 2574, 2662, 3146, 3993, 4719, 7986, 9438, 11979, 14157, 17303, 23958, > 28314, 34606, 51909, 103818, 155727, 311454} > > Divisors[2*3*3*11*11*11*13] - % > > {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

**References**:**Divisors***From:*hahaj@home.com (Hans Havermann)