comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: writing an "artful" algorithm
Date: Fri, 18 Apr 2003 05:51:57 GMT
Date: 2003-04-18T05:51:57+00:00	[thread overview]
Message-ID: <1oMna.263929$Zo.51799@sccrnsc03> (raw)
In-Reply-To: 9BLna.232134$OV.289871@rwcrnsc54

> > there is the condition that no digit can be repeated in either 5-digit
> > number, and all the digits in the product must be unique. One
>
> The approach used here is to generate a list containing all 5 digit numbers
> containing unique digits.  Then sequence through the list generating
> products and testing the unique digits condition on the product.
  Clearly (casting out nines) the product must be a multiple of 9, so
either one of the multipliers is a multiple of 9, ie sum of its digits
mod 9 = 0, or both are multiples of 3, ie, sum of digits mod 3 = 0.
That should reduce the number of trial multiplies.



  reply	other threads:[~2003-04-18  5:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-17 15:12 writing an "artful" algorithm John Stoneham
2003-04-17 22:08 ` Samuel Tardieu
2003-04-17 22:17   ` Samuel Tardieu
2003-04-18  4:57 ` Steve
2003-04-18  5:51   ` tmoran [this message]
2003-04-22 20:38 ` Dan Eilers
2003-04-23 13:12   ` John Stoneham
2003-05-19 23:19 ` John Atwood
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox