#! perl -w # # Multiplication (or addition) tables in various bases # # Copyright 2016 Ken Takusagawa # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . $operator='*'; sub multiply { my($base,$a,$b)=@_; my$answer= `echo "obase=$base;$a$operator$b"|bc`; chomp$answer; $answer } for(0..9,'A'..'Z'){ push @convert,$_; } $start=2; $html_op=qq($operator); for$base(2..16){ print qq(

Base $base
); print qq($html_op); for$i($start..$base-1){ print ""; } print "$html_op\n"; for$i($start..$base-1){ print ""; for$j($start..$base-1){ #print"$base $i $j ",&multiply($base,$i,$j),"\n"; print ""; } print "\n"; } print qq(); for$i($start..$base-1){ print ""; } print "$html_op\n"; print "
$convert[$i]
$convert[$i]",&multiply($base,$i,$j),"$convert[$i]
$operator$convert[$i]

" } print "\n";