use strict;
use warnings;
use bigint;
sub isEgyption{
    my $nr = int($_[0]);
    my $de = int($_[1]);
    if($nr == 0 or $de == 0){
	
	return;
    }
    if($de % $nr == 0){
	
	printf "1/" . int($de/$nr);
	return;
    }
    if($nr % $de == 0){
	
	printf $nr/$de;
	return;
    }
    if($nr > $de){
        printf int($nr/$de) . " + ";
	isEgyption($nr%$de, $de);
	return;
    }
    
    my $tmp = int($de/$nr) + 1;
    printf "1/" . $tmp . " + ";
    isEgyption($nr*$tmp-$de, $de*$tmp);
}

my $nrI = 2014;
my $deI = 59;
printf "\nEgyptian Fraction Representation of " . $nrI . "/" . $deI . " is: \n\n";
isEgyption($nrI,$deI);