This is my code to make the program independent of the number of digits.
I donīt know how to interprete 999 and 99, maybe 10^3-1 and 10^2-1, but I don't know how would be if digits is "6".
999 and 999?
99 and 9999?

Regards
Hopes
#!/usr/bin/perl -w use strict; my $fr; my $low_count; my $digits=5; for my $x (10 .. 99) { for my $y (101 .. 999) { my $result = $x * $y; if ($result < 10**($digits-1)) { $low_count++; next; } my $index; $fr->[5-$index++][$&]++ while ($result =~ /\d/g); } } $fr->[$digits-1][0] = 0; #This line print "$low_count\n\n"; for my $digit (0 .. 9) { print "$digit\t"; for my $exp (reverse 0 .. 4) { print "$fr->[$exp][$digit]\t"; } print "\n"; }

In reply to Re: Frequency analysis of the digits of the result of a multiplication by hopes
in thread Frequency analysis of the digits of the result of a multiplication by perlmoth

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.