MathGroup Archive 2005

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

Search the Archive

Re: Can anyone please help with this mathematica code

"Tony King" <mathstutoring at> wrote in message 
news:d3nvbb$bf4$1 at
>I am looking for a function f[k,n] that will return the k-ary divisors of n
> For example,
> f[0,n] would return the divisors of n
> f[1,n] would return the unitary divisors of n
> f[2,n] would return the 2-ary divisors of n
> f[3,n] would return the 3-ary divisors of n
> And so on
> Many thanks
> Tony

Providing a definition of k-ary divisors would have been helpful. At any 
rate, I believe the following function does what you are looking for.

f[0, n_] := Divisors[n]
f[k_, n_] := Module[{},
 div = Divisors[n];
 maxgcdpower = Max /@ FactorInteger[GCD[div, n/div]][[All,All,2]];
 div[[Flatten[Position[maxgcdpower, a_ /; a < k, 1]]]]

Carl Woll 

  • Prev by Date: Re: Can you type a command and have Mathematica show the parameters?
  • Next by Date: Re: Maping and Complex Addition
  • Previous by thread: Can anyone please help with this mathematica code
  • Next by thread: Mathematica 4.0 can't run under XP.