Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: Selecting numbers with all odd digits

  • To: mathgroup at
  • Subject: [mg22224] Re: Selecting numbers with all odd digits
  • From: "Allan Hayes" <hay at>
  • Date: Fri, 18 Feb 2000 02:35:08 -0500 (EST)
  • References: <88g51o$>
  • Sender: owner-wri-mathgroup at


A slight speed up

Select[Range[6990], Union[OddQ[IntegerDigits[#]]] == {True} &]; // Timing

        {3.35 Second, Null}

Select[Range[6990], Select[IntegerDigits[#], EvenQ, 1] === {} &]; // Timing

        {2.25 Second, Null}

The 1 in the inner Select terminates the test if an even digit is found

Allan Hayes
Mathematica Training and Consulting
Leicester UK
hay at
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"Tom De Vries" <tdevries at> wrote in message
news:88g51o$4ee at
> Hello all,
> In one of the math classes I am teaching we are doing some work with
> permutations and combinations.  One question in the text was,  "how many
> positive integers less than 700 have all odd digits?"
> I had done the question "by hand" and then wondered how to use Mathematica
> to demonstrate that the solution was the correct one.
> I am still very far down on the learning curve in most things, but I
> to bludgeon my way to an answer  (thankfully the same as mine!)
> Select[
>   Range[699],
>   Union[ OddQ [ IntegerDigits[#]]] == {True} &
>   ]
> I am sure my trial and error method can be improved upon.  I am not
> speed as much as simply using Mathematica in a way that makes sense and
> would be more logical??
> Thanks for any suggestions might have!
> Tom De Vries
> Edmonton, Alberta
> Canada

  • Prev by Date: export graphics
  • Next by Date: Re: shell commands in notebooks
  • Previous by thread: Re: Selecting numbers with all odd digits
  • Next by thread: Re: Selecting numbers with all odd digits