       Re: challenge problem

• To: mathgroup at smc.vnet.net
• Subject: [mg61332] Re: challenge problem
• Date: Sun, 16 Oct 2005 00:17:48 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```On 10/14/05 at 10:22 PM,
fred._canxxxel_this_bartoli at RemoveThatAlso_free.fr_AndThisToo (Fred
Bartoli) wrote:

>Hello, I'm a long time lurker here and found this little pb funny,
>so here's how I'd do it.

>The answer is 2191158578348111232  and took only 3 min on my P2/400
>using semi brut force.

>I'll use Pascal's test (see
>http://mathworld.wolfram.com/DivisibilityTests.html )

>A number bellow 10^6 and divisible by 7 must have its 6 digits
>satisfying the following: Mod[ a0 + 3 a1 + 2 a2 - a3 - 3 a4 - 2 a5,
>7] == 0

>A number bellow 10^6 whose reversed digits sequence is divisible by
>7 must have its 6 digits satisfying the following: Mod[ a5 + 3 a4 +
>2 a3 - a2 - 3 a1 - 2 a0, 7] == 0

>For numbers above 10^6, the sequence repeats for the next six
>digits packet and so on...

With this last, you can generate your lists without ever directly testing for divisibility by 7. Clearly, Range[7,10^5,7] contains all possible numbers less than 10^5 that are divisible by 7. So,

list1=
Intersection[#, FromDigits@Reverse@IntegerDigits[#,10,5]&/@#]&#Range[7,10^5,7];

will contain all numbers less than 10^5 meeting the criteria.

Similarly

list2=
Intersection[#, FromDigits@Reverse@IntegerDigits[#,10,6]&/@#]&#Range[7,10^6,7];

will contain all of the numbers less than 10^6 that meet the criteria.

The needed sums are

In:=
{sum1, sum2} = Total /@ {list1, list2}
Out=
{105714126, 10363989636}

with lengths
In:=
{len1, len2} = Length /@ {list1, list2}
Out=
{2112, 20727}

putting it all together the desired sum becomes

In:=
len1*sum2 + 10^6*len2*sum1
Out=
2191158578348111232
--
To reply via email subtract one hundred and four

```

• Prev by Date: Re: Interesting failure of Collect
• Next by Date: Re: DSolve and matrix form of system of equations
• Previous by thread: Re: challenge problem
• Next by thread: TagSet and the listability of Plus[ ]