*** empty log message ***

This commit is contained in:
hjp 2001-01-19 18:37:52 +00:00
parent 6900af48b4
commit 1122091610
3 changed files with 95 additions and 0 deletions

30
fact/GNUmakefile Normal file
View File

@ -0,0 +1,30 @@
include GNUmakevars
CONFDIR=../../configure
all: configure fact
clean:
rm fact customize
install: $(BINDIR) $(BINDIR)/fact
%: %.pl customize
sh ./customize < $< > $@
chmod +x $@
%: %.sh customize
sh ./customize < $< > $@
chmod +x $@
customize: configure
sh ./configure
configure: $(CONFDIR)/start $(CONFDIR)/perl $(CONFDIR)/finish
cat $^ > $@
$(BINDIR):
mkdir -p $@
include GNUmakerules

34
fact/configure vendored Normal file
View File

@ -0,0 +1,34 @@
#!/bin/sh
#
echo "#!/bin/sh" > customize.$$
echo "sed \\" > customize.$$
chmod +x customize.$$
################################################################
# find a working perl:
#
for i in /usr/bin/perl /usr/local/bin/perl /usr/bin/perl5 /usr/local/bin/perl5
do
if $i -e 'exit ($] < 5.000)'
then
echo $i works
perl="$i"
break
fi
done
if [ -z "$perl" ]
then
could not find a working perl command, sorry.
exit 1
fi
echo " -e 's,@@@perl@@@,$perl,g' \\" >> customize.$$
################################################################
# finish
# Add trailing newline and rename temp file to final name
#
echo >> customize.$$
mv customize.$$ customize

31
fact/fact.pl Normal file
View File

@ -0,0 +1,31 @@
#!@@@perl@@@ -w
use strict;
sub usage {
print STDERR "Usage: $0 number\n";
exit(1);
}
sub fact {
my ($n) = @_;
my $d = 2;
my @f = ();
while ($d <= $n) {
if ($n % $d == 0) {
push (@f, $d);
$n /= $d;
} else {
$d++;
}
}
return @f;
}
if (@ARGV != 1) { usage(); }
my @f = fact($ARGV[0]);
print "@f\n";
#vim:sw=4