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: [mg53374] Re: [mg53363] Special Prime Product
  • From: DrBob <drbob at bigfoot.com>
  • Date: Sat, 8 Jan 2005 23:02:35 -0500 (EST)
  • References: <200501080739.CAA17748@smc.vnet.net>
  • Reply-to: drbob at bigfoot.com
  • Sender: owner-wri-mathgroup at wolfram.com

After correcting three mispellings in your code, I get this:

<< NumberTheory`NumberTheoryFunctions`
specpriprod[n_] := Module[{v},
    v = Product[(PrimeFactorList[n][[i]] -
         2)/(PrimeFactorList[n][[i]] - 2),
       {i, Length[PrimeFactorList[n]]}]; v]
Table[{n, specpriprod[n]}, {n, 4, 50, 2}]
(error messages, division by zero)

Each product DOES involve division by zero, since the denominators include all prime factors minus 2, and 2 is a prime factor.

Before going on, let's eliminate trivia in that code:

specpriprod[n_] := Product[(PrimeFactorList[n][[i]] -
     2)/(PrimeFactorList[n][[i]] - 2), {i, Length[PrimeFactorList[n]]}]
Table[{n, specpriprod[n]}, {n, 4, 50, 2}]
(same result)

If division by zero weren't occurring, all the products would be 1, as each multiplied term is (p-2)/(p-2) == 1.

Judging by your "picture" at the top, I assume you meant (p-2)/(p-1), so:

specpriprod[n_] := Product[(PrimeFactorList[n][[i]] -
     2)/(PrimeFactorList[n][[i]] - 1), {i, Length[PrimeFactorList[n]]}]
Table[{n, specpriprod[n]}, {n, 4, 50, 2}]
{{4, 0}, {6, 0}, {8, 0}, {10, 0}, {12, 0}, {14, 0},
   {16, 0}, {18, 0}, {20, 0}, {22, 0}, {24, 0}, {26, 0},
   {28, 0}, {30, 0}, {32, 0}, {34, 0}, {36, 0}, {38, 0},
   {40, 0}, {42, 0}, {44, 0}, {46, 0}, {48, 0}, {50, 0}}

These are all zero because each product has p - 2 in one of the numerators, with p = 2.

Now, assuming you wanted to leave out p=2 so the answers aren't all zero, here's the product:

prod[n_?EvenQ] := Module[{v = Rest@PrimeFactorList@n},
         Times @@ (v - 2)/Times @@ (v - 1)]
Table[{n, prod[n]}, {n, 4, 50, 2}]

{{4, 1}, {6, 1/2}, {8, 1}, {10, 3/4}, {12, 1/2},
   {14, 5/6}, {16, 1}, {18, 1/2}, {20, 3/4}, {22, 9/10},
   {24, 1/2}, {26, 11/12}, {28, 5/6}, {30, 3/8}, {32, 1},
   {34, 15/16}, {36, 1/2}, {38, 17/18}, {40, 3/4},
   {42, 5/12}, {44, 9/10}, {46, 21/22}, {48, 1/2}, {50, 3/4}}

or

prod[n_?EvenQ] := Times @@ ((#1 - 2)/(#1 - 1)) &@Rest@PrimeFactorList@n
Table[{n, prod[n]}, {n, 4, 50, 2}]
(same answers)

I assume the errors in your code came from typing it manually into e-mail (rather than copy-and-paste from working code). DON'T DO THAT. It wastes your time and everybody else's too, and will often get you an answer to the wrong question.

If copy and paste doesn't work well "as is", select the cell you want and use the menu option Cell>Convert to>InputForm (or press Shift-Ctrl-I), then copy and paste.

Bobby

On Sat, 8 Jan 2005 02:39:30 -0500 (EST), Gilmar <gilmar.rodriguez at nwfwmd.state.fl.us> 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!
>
>
>
>



-- 
DrBob at bigfoot.com
www.eclecticdreams.net


  • Prev by Date: Re: Converting between Spherical and Cartesian coordinates
  • Next by Date: Re: Special Prime Product
  • Previous by thread: Special Prime Product
  • Next by thread: Re: Special Prime Product