MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

How can I get Divisors[n] from FactorInteger[n]?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19904] How can I get Divisors[n] from FactorInteger[n]?
  • From: Julian Aguirre Estibalez <mtpagesj at lg.ehu.es>
  • Date: Tue, 21 Sep 1999 02:22:43 -0400
  • Organization: Universidad del Pais Vasco/Euskal Herriko Unibertsitatea
  • Sender: owner-wri-mathgroup at wolfram.com

Dear Math Group,

	I am doing some calculations where I need at the same time the set
of divisors and the prime factors of an integer n. I would like to get the
divisors of n from its factorization into primes. I have come up with the
following code:

ClearAll[ g, mydiv ];
g[{x__}] := Outer[ Times, x ];
SetAttributes[ mydiv, Listable ];
mydiv[n_Integer] := With[ { pf = FactorInteger[n] },
		          { First/@fp, g[First/@fp^Range[0,Last/@fp]] }
		        ]

	It is more efficient than calling Divisors[n] and FactorInteger[n]
(or Select[Divisors[n],PrimeQ]) only  if n has 10 or more digits. Can any
one suggest a more efficient code?

Julian Aguirre			| Voice:  +34 946012659
Departamento de Matematicas	| Fax:    +34 944648500
Universidad del Pais Vasco	| Postal: Aptdo. 644, 48080 Bilbao, Spain
				| email:  mtpagesj at lg.ehu.es



  • Prev by Date: Re: Solving equations involving Ln function
  • Next by Date: Re: Fast List-Selection
  • Previous by thread: Symbolic Derivatives with respect to a vector
  • Next by thread: Challenge Mathematica vs Excel Addins