> He is a scientist, so I trust him :-)

Thanks, this makes sense and is indeed connected to the digit sum. :)

(And it's not too hard to understand. But I don't wanna bore you with calculations)

What you are doing is called "sieving", because you apply patterns at repeating steps to avoid futile calculations.

But you could create more complicated sieves

Eg if the first digit is i the max k is 9/i (2-> 4, 3->3, 4->2, 5..9 ->1)

So you can skip looping from 5xxx to 9xxx.

This can be even improved, if the biggest digit is m, max k becomes m/i but that's harder to implement.

Or a k=5 is only possible if you have at least one digit 0 or 5.

Combining all these sieves can get quite complicated and the overhead might not justify it.

But you don't need to search sequentially as long as you cover all integers in an interval.

If you really want to break further speed records inform yourself about techniques of (prime) number searches with sieves.

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery


In reply to Re^3: Faster (but uglier) PWC 350-2 solutions by LanX
in thread Faster (but uglier) PWC 350-2 solutions by Anonymous Monk

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.