Reducing Leibniz perl code in characters This Perl code is supposed to calculate the Leibniz formula. The original problem is here.

The input format is:

T
&lt;T test cases, each on their own line&gt;


Each test case is a number &lt; 10^7. The output format should be the same, minus the first line.

For example, an input:

2 
10 
20


And for output:

0.760459904732351
0.77290595166696


My first solutions, at 62 and 61 characters respectively.

for(1..&lt;&gt;){$s=0;map{$s+=($_&amp;1||-1)/(2*$_-1)}1..&lt;&gt;;print"$s\n"}

for(1..&lt;&gt;){$s=0;$s+=($_&amp;1||-1)/(2*$_-1)for 1..&lt;&gt;;print"$s\n"}


Edit: The best solution so far is 53 characters, by @teebee:

&lt;&gt;;print${\map$a-=(-1)**$_/(2*$_-1),1..$_},$a=$/for&lt;&gt;
Perl 53 bytes

You can save two more strokes:

&lt;&gt;;print${\map$a-=(-1)**$_/(2*$_-1),1..$_},$a=$/for&lt;&gt;