Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • The sum of the digits of a number mod 9 is always the number mod 9. The sum of the digits of 2*$n and 3*$n is the same, which means that mod 9, 2*$n and 3*$n are the same, which means that $n is 0 mod 9, so $n is divisible by 9.

    This should improve your speed by a factor of 3. :-)

    • Huh. I don't follow your logic -- I don't know anything about sum of the digits being the same means the numbers are the same mod 9. BUT a web search trying to turn up more on it found a proof that "The difference of any two numbers composed of the same digits is always a multiple of nine." In which case 3*$n - 2*$n = $n is a multiple of nine, so your conclusion is dead on correct. Thanks!