MathGroup Archive 2010

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

Search the Archive

Re: sieving out selected multiples

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113819] Re: sieving out selected multiples
  • From: Tomas Garza <tgarza10 at msn.com>
  • Date: Sun, 14 Nov 2010 06:09:35 -0500 (EST)

Take the list

In[1]:== lst == Range[100]

Out[1]== {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, \
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, \
35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, \
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, \
69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, \
86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100}

Deleting all multiples of 5 (including 5 itself):

In[2]:== int == 5; DeleteCases[lst, x_ /; Mod[x, int] ==== 0]

Out[2]== {1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, \
22, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 36, 37, 38, 39, 41, 42, \
43, 44, 46, 47, 48, 49, 51, 52, 53, 54, 56, 57, 58, 59, 61, 62, 63, \
64, 66, 67, 68, 69, 71, 72, 73, 74, 76, 77, 78, 79, 81, 82, 83, 84, \
86, 87, 88, 89, 91, 92, 93, 94, 96, 97, 98, 99}

Deleting all multiples of 5 and 8 (including both 5 and 8):

In[3]:== int1 == 5; int2 == 8;

DeleteCases[lst,
 x_ /; Mod[x, int1] ==== 0 || Mod[x, int2] ==== 0]

Out[3]== {1, 2, 3, 4, 6, 7, 9, 11, 12, 13, 14, 17, 18, 19, 21, 22, 23, \
26, 27, 28, 29, 31, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44, 46, 47, \
49, 51, 52, 53, 54, 57, 58, 59, 61, 62, 63, 66, 67, 68, 69, 71, 73, \
74, 76, 77, 78, 79, 81, 82, 83, 84, 86, 87, 89, 91, 92, 93, 94, 97, \
98, 99}

-Tomas

> Date: Sat, 13 Nov 2010 00:58:52 -0500
> From: andrea at radargift.com
> Subject: [mg113794] sieving out selected multiples
> To: mathgroup at smc.vnet.net
>
> What is the simplest way to delete -- i.e., remove -- the multiples an
> integer from a list?
> And what is the simplest way to delete, simultaneously, the multiples from
> more than one selected integer from a list?
>
> I couldn't find a simple Mathematica function for this.
>
> Thanks,
> Andrea
>
>


  • Prev by Date: Re: Sort a List, in a List of Lists of Lists
  • Next by Date: Re: Sort a List, in a List of Lists of Lists
  • Previous by thread: Re: sieving out selected multiples
  • Next by thread: Table local