#!/usr/bin/perl
# Author: Kumcho Vulcho
# $Id$
#
# 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 2 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 Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

use strict;
use warnings;

for my $base (2..9) {
	for $a (1..10) {
		for $b (1..10) {
			print "Base:$base - $a*$b = ", _( ( $a * $b ), $base), "\n";
		}
	} # 1 to 10 to multyply
} # base systems

sub _ {
	my($num, $base) = @_;
	
	die "I don't think that base will work so well.\n" if $base < 2;
	die "We do not support bases bigger than 9.\n" if $base > 9;
	
	my $radix = '';
	do {
		my $res = int $num/$base;
		my $mod = $num%$base;
		
		$radix = $mod.$radix;
		$num = $res;
	} while ($num > 0);
	
	return $radix;
}


__END__