Re: Selecting numbers with all odd digits

• To: mathgroup at smc.vnet.net
• Subject: [mg22222] Re: [mg22170] Selecting numbers with all odd digits
• From: "David Park" <djmp at earthlink.net>
• Date: Fri, 18 Feb 2000 02:35:06 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Hi Tom,

Well, since the text didn't ask for a list of the integers but only the number of
integers we note that there are 3 odd digits in the range 1 to 5, and 5 odd digits in
the range 1 to 9. Then we have to consider 3 digit integers, 2 digit integers and 1
digit integers giving

3*5*5 + 5*5 + 5
105

But then your nice method is very good to check that we haven't gone wrong in our
thinking, like did we remember the 2 digit and 1 digit integers?

I somewhat more efficient method to generate the numbers might be:

Join[Flatten[
Outer[100#1 + 10#2 + #3 &, Range[1, 5, 2], Range[1, 9, 2],
Range[1, 9, 2]]],
Flatten[Outer[10#1 + #2 &, Range[1, 9, 2], Range[1, 9, 2]]],
Range[1, 9, 2]] // Sort
Length[%]

{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 31, 33, 35, 37, 39,
51, 53, 55, 57, 59, 71, 73, 75, 77, 79, 91, 93, 95,
97, 99, 111, 113, 115, 117, 119, 131, 133, 135, 137,
139, 151, 153, 155, 157, 159, 171, 173, 175, 177, 179,
191, 193, 195, 197, 199, 311, 313, 315, 317, 319, 331,
333, 335, 337, 339, 351, 353, 355, 357, 359, 371, 373,
375, 377, 379, 391, 393, 395, 397, 399, 511, 513, 515,
517, 519, 531, 533, 535, 537, 539, 551, 553, 555, 557,
559, 571, 573, 575, 577, 579, 591, 593, 595, 597, 599}

105

David Park

>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 managed
>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 talking
>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