       Re: Easiest Mathematica algorhitm needed

• To: mathgroup at smc.vnet.net
• Subject: [mg92822] Re: Easiest Mathematica algorhitm needed
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Tue, 14 Oct 2008 04:57:31 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <gcq09i\$c30\$1@smc.vnet.net> <200810120835.EAA08892@smc.vnet.net> <gcv7ef\$e31\$1@smc.vnet.net>

```Artur wrote:

> Who know which Matrhematica function uses to separate square free part
> of number.

Pattern matching seems the more appropriate.

> e.g.
> In: Table[Sqrt[n!], {n, 1, 10}]
> Out: {1, Sqrt, Sqrt, 2 Sqrt, 2 Sqrt, 12 Sqrt, 12
> Sqrt,
>  24 Sqrt, 72 Sqrt, 720 Sqrt}
> What to do to take squre-free parts:
> {1, 2, 6, 6, 30, 5, 35, 70, 70, 7}

In:= lst = Table[Sqrt[n!], {n, 1, 10}]

Out= {1, Sqrt, Sqrt, 2 Sqrt, 2 Sqrt, 12 Sqrt,
12 Sqrt, 24 Sqrt, 72 Sqrt, 720 Sqrt}

In:= Cases[lst, ___*Sqrt[n_] | Sqrt[n_] -> n]

Out= {2, 6, 6, 30, 5, 35, 70, 70, 7}

> or square parts
> {1, 1, 1, 2, 2, 12, 12, 24, 72, 720}

In:= List @@ lst /. Sqrt[__] -> 1

Out= {1, 1, 1, 2, 2, 12, 12, 24, 72, 720}

HTH,
-- Jean-Marc

```

• Prev by Date: Re: Exclude O[] from Series[] for Solve[] in Mathematica
• Next by Date: Re: Exclude O[] from Series[] for Solve[] in Mathematica
• Previous by thread: Re: Easiest Mathematica algorhitm needed
• Next by thread: Re: Executing external notebook