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: Special Prime Product

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53381] Re: Special Prime Product
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Sat, 8 Jan 2005 23:02:43 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On 1/8/05 at 2:39 AM, gilmar.rodriguez at nwfwmd.state.fl.us (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. 

But for any even number 2 will be a prime factor. That means p-2 evaluates to zero and the product must be zero. So, there is no apparent problem with the results.

I do note your code could be improved and will not do what you describe as written. You are using primeFactorList instead of PrimeFactorList and you have p-2 in the demonimator. Also, you do not need the local variable v.

A better approach would be

specpriprod[n_]:=
Module[{p = PrimeFactorList[n]},
  Product[(p[[i]]-2)/(p[[i]]-1),{i,Length[p]}]]

And even easier to read and probably more efficient is

specpriprod[n_]:=
Module[{p = PrimeFactorList[n]},
  Times@@((p-2)/(p-1))]
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Function Show[]
  • Next by Date: Re: Plotting dates on the x-axis
  • Previous by thread: Re: Special Prime Product
  • Next by thread: Re: Special Prime Product