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

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"; }
  • Comment on Re: Frequency analysis of the digits of the result of a multiplication
  • Download Code