#!/usr/bin/perl
#
# Euler's totient function
# If N=p1^e1...pn^en then phi(N)=N/(1-1/p1)...(1-1/pn).

die "Usage: $0 number\n" if ($#ARGV != 0);
$N = shift;
$N =~ s/^[+-]//;  # Remove the sign
if ($N eq "0" || $N eq "1") {
	print "$N\n";
	exit 0;
}
open(STDOUT, "|samuel -bZ");
print "$N";
chop ($factors = `factorint $N`);
foreach $p (split(/\./,$factors)) {
	$p =~ s/\^\d+//;  # Remove the exponent
	print "/$p.($p-1)";
}	
print ";\n";
close STDOUT;
exit 0;
