• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: A puzzle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A puzzle


  • Subject: Re: A puzzle
  • From: "Mark J. Reed" <email@hidden>
  • Date: Fri, 21 Nov 2008 16:43:06 -0500

On Fri, Nov 21, 2008 at 4:19 PM, Luther Fuller <email@hidden> wrote:
> But, what if we let d = 0? If we use the brute force script, we find that if
> n = 6, then there are 488890 zeros in the print-out. Of course, the answer
> is different in this case since leading zeros aren't printed.

Well, in an odometer, at least a traditional mechanical one, the
leading zeroes are there.  But assume it's digital and leading zeroes
don't count.  Then you have to construct a sum.  Start with the same
total (n * 10^(n-1)).

1. Subtract any zeroes that appear in the high digit; there's one of
those for every possible value of the remaining digits, so that's
10^(n-1).
2. Subtract any zeroes in the second-to-highest digit that occur when
the high digit is zero: that's 10^(n-2).

Etc.  Continue counting down and subtracting.

600000 - 100000 - 10000 - 1000 - 100 - 10 - 1 = 488889.

but then you have to add 1 back for the case where the total value is
0, even though that's technically a "leading" zero.

488889 + 1 = 488890.

So the general result is  n * 10^(n-1) - [sum from 1 to n of 10^n] +
1.  Of course, that middle number is just a sequence of '1's of length
n, easily written down directly when you know n:

600000 - 111111 + 1 = 488890.







--
Mark J. Reed <email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: A puzzle
      • From: Luther Fuller <email@hidden>
    • Re: A puzzle
      • From: Skeeve <email@hidden>
    • Re: A puzzle
      • From: Deivy Marck Petrescu <email@hidden>
References: 
 >A puzzle (From: Michelle Steiner <email@hidden>)
 >Re: A puzzle (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: A puzzle
  • Next by Date: Re: A puzzle
  • Previous by thread: Re: A puzzle
  • Next by thread: Re: A puzzle
  • Index(es):
    • Date
    • Thread