Re: challenge problem

• To: mathgroup at smc.vnet.net
• Subject: [mg61271] Re: [mg61219] challenge problem
• From: János <janos.lobb at yale.edu>
• Date: Fri, 14 Oct 2005 05:54:25 -0400 (EDT)
• References: <200510130539.BAA04503@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```On Oct 13, 2005, at 1:39 AM, Murray Eisenberg wrote:

> At http://www.itasoftware.com/careers/eng/job1.php, there are a number
> of interestng programming problems posed.  One, the "Lucky Sevens", is
> to write a program that will find the sum of all those integers
> between
> 1 and 10^11 that are divisible by 7 AND whose reversed-digit forms are
> also divisible by 7.
>
> I should think that an elegant and possibly efficient solution in
> Mathematica would be to use the form func /@ Range[10^11].  But since
> Mathematica 5.2 on my my 32-bit Windows machine won't let me form
> Range[10^11], a 64-bit architecture would seem to be required.
>
>
> --
> Murray Eisenberg                     murray at math.umass.edu
> Mathematics & Statistics Dept.
> Lederle Graduate Research Tower      phone 413 549-1020 (H)
> University of Massachusetts                413 545-2859 (W)
> 710 North Pleasant Street            fax   413 545-1801
> Amherst, MA 01003-9305

Here is a newbie approach:

n=8

In[30]:=
Timing[Total[First[
Last[Reap[i = 7;
maxi = 10^7; While[
i < maxi,
If[Mod[FromDigits[
Reverse[
IntegerDigits[i]]],
7] == 0, Sow[i]];
i += 7]]]]]]

Out[35]=
{426.28709100000003*Second,
102184086890270}

For n=11 it would take 5  and half days on my G4 :)

Probably faster ways can be done if you code out the divisibility
tests from http://mathworld.wolfram.com/DivisibilityTests.html and
use them instead of Mod.  I do not know how Mod is optimized for
bigger numbers.

János

```

• Prev by Date: Re: TagSet and the listability of Plus[ ]
• Next by Date: Re: Re: Re: Language vs. Library
• Previous by thread: Re: challenge problem
• Next by thread: Re: challenge problem