#!/usr/bin/perl
#
# Szamolgato v1.0, 99/10/13
# (c)1999 peter 'grin' gervai
#
# kiirja egy szam erteket betukkel
#
$n=$ARGV[0] + 0;
print "$n = ",&betukre($n),"\n";
#print &betukre($n),"\n";
sub betukre {
my $n = shift;
my @SZAM = ( 'nulla','egy','kett??','h??rom','n??gy','??t','hat','h??t','nyolc','kilenc' );
my @TIZES= ( '','tizen','huszon','harminc','negyven','??tven','hatvan','hetven','nyolcvan','kilencven' );
#my @HATVANY=( 'sz??z','ezer','milli??','milli??rd', 'billi??', 'billi??rd','trilli??',
# 'trilli??rd', 'kvadrilli??', 'kvadrilli??rd', );
# my @EXP = ( 2, 3, 6, 9, 12, 15, 18 );
my @HATVANY = qw( sz??z ezer );
my @EXP = ( 2, 3 );
# \/ idaig tart a szamabrazolas :)
my @hatvanyok1 = qw( milli billi trilli kvadrilli kvintilli szextilli
szeptilli oktilli nonilli decilli undecilli bidecilli tridecilli kvadecilli kvintdecilli szexdecilli );
for my $i ( 1..16 ) {
push @HATVANY, $hatvanyok1[$i-1] . '??';
push @EXP, $i*6;
push @HATVANY, $hatvanyok1[$i-1] . '??rd';
push @EXP, $i*6+3;
}
push @HATVANY, 'googol';
push @EXP, 100;
push @HATVANY, 'centilli??';
push @EXP, 600;
# 1 googolplex = 10^googol = 10^(10^100)
my $out = "";
for( my $hatv=$#HATVANY; $hatv>=0; $hatv-- ) {
# 10^$hatv az alap
my $hatv_num = $EXP[$hatv];
my $alap = "1e$hatv_num" + 0;
if( $n>=$alap ) {
my $resz = int($n / $alap);
$out .= '-' if $out ne '';
$out = $out . &betukre($resz) . $HATVANY[$hatv];
$n -= $resz * $alap;
}
}
if( $n > 99 ) {
$out .= '-' if $out ne '';
$out .= "SOK";
} elsif( $n > 9 ) {
$out .= '-' if $out ne '';
if( $n==10 ) {
$out .= 't??z';
} elsif( $n==20 ) {
$out .= 'h??sz';
} else {
my $tizen = int( $n / 10);
$out .= $TIZES[$tizen] unless $tizen==0;
my $egyen = $n - ($tizen * 10);
$out .= $SZAM[$egyen] unless $egyen==0;
}
} elsif( $n > 0 ) {
$out .= '-' if $out ne '';
$out .= $SZAM[$n];
}
return $out;
}