On Mon, 23 Feb 2015 20:21:19 +0000, Charles wrote: > My solution (150 characters, 15 points): > > void main(){import std.stdio;int t,n;readf(" > %d",&t);while(t--){readf(" %d",&n);real > a=0,i=0;for(;i<n;i++)a+=(i%2?-1:1)/(i+i+1);writefln("%.15f",a);}} > > Link to problem site: https://www.hackerrank.com/challenges/leibniz > > Anyone care to do better? :)
Minor refactorings of your solution to get 15.7: https:// www.hackerrank.com/challenges/leibniz/submissions/code/11073459 Dirty solution (read and decrement a real as if it's a int), but passes the test cases.