Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Can anyone please help with this mathematica code

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56147] Re: Can anyone please help with this mathematica code
  • From: "Carl K. Woll" <carlw at u.washington.edu>
  • Date: Sat, 16 Apr 2005 03:53:32 -0400 (EDT)
  • Organization: University of Washington
  • References: <d3nvbb$bf4$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Tony King" <mathstutoring at ntlworld.com> wrote in message 
news:d3nvbb$bf4$1 at smc.vnet.net...
>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.