MathGroup Archive 2005

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

Search the Archive

Re: Special Prime Product

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53379] Re: [mg53363] Special Prime Product
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Sat, 8 Jan 2005 23:02:40 -0500 (EST)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200501080739.CAA17748@smc.vnet.net>
  • Reply-to: murray at math.umass.edu
  • Sender: owner-wri-mathgroup at wolfram.com

Why are you surprised at the result?  After all, if n is even, then 2 is 
a prime divisor of n and so one of the factors in the product you form 
is (2 - 2)/(2 - 1).

So I'm assuming there is some error in your description of the product 
you actually want.

Also, you made some typos:  You used lower-case "primeFactorList" within 
the definitin of specpriprod; you need to use "PrimeFactorList".  And 
your definition was of a function "specpriprod" whereas in your Table 
expression that called it, you used "specprimprod".

In any case, I have a couple of recommendations.  First, why not follow 
the Mathematica convention of meaningful names and name your function 
specialPrimeProduct?  That way you might avoid the second of those typos.

Second, your definition needlessly invokes PrimeFactorList twice and 
then needlessly indexes into it.  You could do the whole thing as 
follows, making use of Mathematica's list-manipulation ability:

    specialPrimeProduct[n_] :=
       Module[{primes = PrimeFactorList[n]},
          Times @@ (primes - 2)/(primes - 1)]

Of course if you are working with a really large n -- not the case at 
all in your example -- then any advantage in efficiency of the above 
code might be offset by use of a lot of memory to store temporarily the 
entire list PrimeFactorList[n].


Gilmar wrote:
> I'm attempting to form a product:
> _____
> |  | (p-2)
> |  | -------
> |  | (p-1)
> p Prime, p|n
> 
> I call the program:
> 
> << NumberTheory`NumberTheoryFunctions`
> and use the function "PrimeFactorList" in it,  to build
> the following module:
> 
> specpriprod[n_]:=
> Module[{v},v=Product[(primeFactorList[n][[i]]-2)/(primeFactorList[n][[i]]-2),
> {i,Length[PrimeFactorList[n]]}];v]
> 
> specpriprod is an abbreviation for "Special Prime Product".
> 
> When I evaluate:
> Table[{n,specprimprod[n]},{n,4,100,2}]
> 
> I only get specprimprod[n] = 0 for n even between 4 and 100.
> Help! and Thank you for your help!
> 
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: Special Prime Product
  • Next by Date: 2D plot for lists?
  • Previous by thread: Re: Special Prime Product
  • Next by thread: Re: Special Prime Product