MathGroup Archive 2009

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

Search the Archive

Re: Test for composite digit

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94964] Re: Test for composite digit
  • From: David Bailey <dave at removedbailey.co.uk>
  • Date: Thu, 1 Jan 2009 07:26:31 -0500 (EST)
  • References: <gjfjne$d3s$1@smc.vnet.net>

Diana wrote:
> Math folks,
> 
> I am trying to write an algorithm which will test for a digit within a
> number being composite, i.e. {4, 6, 8, or 9}
> 
> For example:
> 
> Let's say I start with the number 844. The next number in my sequence
> will be the smallest number greater than 844 which satisfies:
> 
> 1) a three digit number with first and third digits composite, and the
> second digit not composite, or a
> 2) a four digit number with first and third digits composite, and the
> second and fourth digits not composite.
> 
> The answer will be 854, and I want the algorithm to be able to find
> this.
> 
> I may then want to find a number of any specified arbitrary length
> with digits composite or not composite as desired.
> 
> Thanks,
> 
> Diana
> 
This is how to split an integer into digits (not characters, but actual 
numbers):

IntegerDigits[844]

I am guessing that this is the help you need to write your code.

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: Combining Plots with Different Ordinate Axes in
  • Next by Date: Re: Combining Plots with Different Ordinate Axes in
  • Previous by thread: Re: Combining Plots with Different Ordinate Axes in
  • Next by thread: Re: Test for composite digit