emacs를 설치하고 써보려 했지만 anti-aliasing font이 깔끔하게 표현되지 않았고, perl programming하기에는 vim이 더 편한 것 같아서 vim을 설치하기로 했다.
cd /usr/ports/editors/vimWITH_GTK2를 하지 않으면 gvim이 GTK1을 사용하게 된다.
make WITH_GTK2=YES install clean
설치 완료 후 GTK2와 잘 조합된 모습. 컬러 스킴은 wombat을 사용했다.
cd /usr/ports/editors/vimWITH_GTK2를 하지 않으면 gvim이 GTK1을 사용하게 된다.
make WITH_GTK2=YES install clean
What are the largest values of n for which n! has fewer then 100 decimal digits, fewer than 1000 decimal digits, and fewer than 10,000 decimal digits?라는 질문을 보고 간단히 perl script로 결과를 구해봤다.
use strict;
use bigint;
my $d = 10000;
my ($i, $n) = (1, 1);
while(1)
{
$n *= $i;
last if length($n * $i) >= $d;
$i++;
}
print "$i factorial: $n [", length($n), " digits]\n";
use strict;
my @seq = ulam(seed => [1, 2], max => 100);
print "@seq\n";
sub ulam()
{
my %args = @_;
my @ulam = @{$args{seed}};
my $max = $args{max};
my ($i, $j) = (0, 1);
my @dups;
while(1)
{
my $s = $ulam[$i] + $ulam[$j];
push @ulam, $s;
if($i + 1 == $j)
{
$j++; $i = 0;
my (@dup, %seen);
foreach (@ulam) { push @dup, $_ if $seen{$_}++ } # find duplications
push @dups, @dup; # save duplications
foreach (@dups) { $seen{$_}++ } # update the duplication record
my @dup_removed;
foreach (@ulam) { push @dup_removed, $_ if $seen{$_} == 1 } # remove duplications
@ulam = sort {$a <=> $b} @dup_removed;
last if($ulam[$j] > $max);
}
else
{
$i++;
}
}
$#ulam = $j - 1;
return @ulam;
}
1 2 3 4 6 8 11 13 16 18 26 28 36 38 47 48 53 57 62 69 72 77 82 87 97 99위키피디아에 보여지는 것과 동일한 결과를 얻을 수 있었다.