Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*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 smc.vnet.net
  • Subject: [mg22253] Re: [mg22170] Selecting numbers with all odd digits
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Sat, 19 Feb 2000 01:33:57 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

I noticed that in a fit of blindeness I put a spurious  ==True into a
predicate. The correct code is of course:

Select[ Range[699], And @@ OddQ[IntegerDigits[#]]&]


-- 

on 2/17/00 4:30 PM, Andrzej Kozlowski at andrzej at platon.c.u-tokyo.ac.jp
wrote:

> on 00.2.17 3:23 PM, Tom De Vries at tdevries at shop.westworld.ca wrote:
> 
>> 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
>> Canada
>> 
>> 
> 
> Your code is basically fine. The following seems to me just a little bit
> more natural and also somewhat faster:
> 
> 
> In[5]:=
> Select[ Range[10^5], And @@ OddQ [ IntegerDigits[#]] == True & ]; // Timing
> Out[5]=
> {13.7167 Second, Null}
> In[6]:=
> Select[Range[10^5], Union[ OddQ [ IntegerDigits[#]]] == {True} & ]; //
> Timing
> Out[6]=
> {23.7 Second, Null}
> 
> --
> Andrzej Kozlowski
> Toyama International University
> Toyama, Japan
> http://sigma.tuins.ac.jp/
> 
> 


Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp




  • Prev by Date: Re: Exporting BMP files in M4
  • Next by Date: Re: pure functions (or not?)
  • Previous by thread: Re: Selecting numbers with all odd digits
  • Next by thread: Compiled