Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

This can also be solved by arithmetic quite readily.

The sum of the digits 1 .. 9 is 45.

Each digit appears 1000 times in each of the units, 10s, 100s and 1000s places.

The units always count as themselves: total 1000 * 45.

The tens are followed by a zero 1/10 of the time: total (100 + 900 * 10) * 45.

The hundreds are directly followed by a zero 1/10 of the time, and followed by a non-zero digit then a zero 1/10 of the remaining: total (100 + 90 * 10 + 810 * 100) * 45.

Similarly for the thousands: total (100 + 90 * 10 + 81 * 100 + 729 * 1000) * 45.

So the sum is (1300 + 1080 * 10 + 891 * 100 + 729 * 1000) * 45 = 830200 * 45 = 37,359,000

This approach can readily be adapted to base b, and beyond to the eat digits 0 .. x-1 required for part 2 of the puzzle.

Hugo


In reply to Re: Ponder This: the worm-eaten page by hv
in thread Ponder This: the worm-eaten page by gaal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-19 20:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found