#!/usr/bin/perl -wl

#for (0..0xfffff) {
#	next unless $_ % 2;
#	$pi .= ($sign++ % 2 == 1 ? "-" : "+") . "1/$_";
#}
#print 4 * eval "$pi";

sub pi {
  my $n = shift;
  my $pi = 0;
  my $f = 1;
  while ($n--) {
    $pi += $f * 1/($n*2+1);
    $f *= -1;
  }
  return 4*abs($pi);
}

print pi(1001);
