in reply to Frequency analysis of the digits of the result of a multiplication

There's definitely an easier way to build up your arrays:
foreach my $x ( 10..99 ) { foreach my $y ( 10..999 ) { @result = reverse split //, $x*$y; $fr[ $_ ][ $result[$_] ]++ foreach (0..$#result); } }
And to remove that uninitialized value, you can do something like:
my @fr; $fr[$_] = [ (0)x10 ] foreach (0..$maxdigits);
where $maxdigits is the largest number of digits you expect in your results.

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important

Replies are listed 'Best First'.
Re: Re: Frequency analysis of the digits of the result of a multiplication
by perlmoth (Hermit) on Nov 18, 2001 at 22:46 UTC
    Thanks for that.

    I found that after getting @result, I had to add:
    while (scalar @result < $maxdigits) { push @result, 0; }
    to cope with when the result is less than $maxdigits in length. (M-x mpuz, which is behind why I wrote this code in the first place, throws away results less than 5 digits in length anyway.)