# How to ask Mathematica to range all the natural numbers $1<n<500$ which are not multiples of 5? [closed]

How can I ask Mathematica to range all the natural numbers $$1 which are not multiples of 5? I mean I need to get $$\{1,2,3,4,6,7,8,9,11,12,13,14,16,...,499\}$$

• To list two ways to do this: Array[If[FractionalPart[#/5] == 0, Nothing, #] &, 500] and Flatten[Array[{-4, -3, -2, -1} + 5*# &, 100]] both work.
– N0va
Commented Oct 28, 2020 at 18:26
• Drop[Range@500, 5 ;; ;; 5] Commented Oct 28, 2020 at 18:33
• Pick[Range[500], Unitize@Mod[Range[500], 5], 1] Commented Oct 28, 2020 at 18:33
• You can generalize the first option given in my earlier comment to exclude even terms as well by modifying the If statement.
– N0va
Commented Oct 28, 2020 at 18:53
• This is clearly a homework question. What have you tried so far? Commented Oct 28, 2020 at 19:21

Sort[ n /. FindInstance[ {

which finds all integers n between 1 and 500 exclusive which are not multiples of 5. You can use other conditions and constraints on n.