Today I thought I'd implement a way to compute pi using continued fractions
I was trying to get 1000 decimals for codegolf.com , but I was only able to get 10 correct
decimals(yes, I know..pathetic) in 6 seconds(codegolf limits this to 4 seconds).
I used the formula here(the one in the middle),and wrote code that weighs at about 140 bytes , but the 1st entry in codegolf.com for this problem has 54 bytes or so.
Anyone care to divulge their (partial) solution to this ?
Maybe they treat the problem as one of compressing those 1000 digits rather than computing them? And if so, I think there were some theoretical bounds to compressing data, I do not remember what those were ... I'm pretty sure codegolf doesn't allow use of modules and implementing your own compression algo would jump over 54bytes for sure , or not ?
use bignum qw/p -20/;
my ($pi,$n) = ('3+1/(X)',1500);
$pi =~ s{X}{
'6'.
(
$_!=$n
?'+'.((2*$_+1)**2).'/(X)'
:''
)
}e for(1..$n);
print eval $pi;