SUMUP - Sum the Series

no tags 

Nilendu is a brilliant student of Mathematics and always scores A+ in it. His professor RamjiLal is quite impressed seeing his mathematical skills and asks him to sum the following series:

1/3 + 2/21 + 3/91 + 4/273 + .....

But the fact is Nilendu is quite lazy to do his assignment. He has to watch a film and many other activities to do. So he asks you for your help. Will you be able to solve it ??

Input

Input consists of t (number of test cases), then t line follows, each containing an integer N (1 <= N <= 10,000).

Output

A single line containing the sum upto Nth integer (rounded upto 5 digits)

Example

Input:
5
1
2
3
4
5

 Output: 0.33333
0.42857
0.46154
0.47619
0.48387

Edit: The score is your source length. The smaller your code is, the more point you will get. All the solutions have been rejudged !!!

hide comments
Mitch Schwartz: 2014-01-03 19:33:01

@Amitayush Thakur: Your comment is unfortunately nonsense. Actually for these types of problems there are an infinite number of valid sequences with a "simple" formula when given the first n terms, for n arbitrary large. Just look up interpolating polynomial. SUMUP would normally be in riddle, but I consider it "grandfathered in" and with some justification: the intended formula is not too convoluted, and it has proven interesting for golf. EASYPROB, EPROBLEM, and HARDP have also been allowed to stay in classical or challenge for similar reasons.

Last edit: 2014-01-03 20:57:49
Amitayush Thakur: 2014-01-02 08:41:53

@Better late than never!!! :
One more term should be given in order to fix the general term.There can be one more series with general term n/(10n^3-34n^2+50n-23) which satisfies the given series but will give WA.The question is more based on guessing.

Gaurav Mishra: 2013-08-29 13:20:43

wat is output fr 316, is it 0.5 and fr 315 0.49999??

Dominique VAILLANT: 2013-08-12 05:16:21

@Mitch: Wow! 52 in Ruby!? I will reconsider the problem at the very begining...

Mitch Schwartz: 2013-08-12 02:58:50

We might need to open a new thread on the forum just for giving each other congratulations. ;) @Dominique: I don't know what technique enabled you to gain that byte, although I can take some guesses; and I noticed you took the top Ruby spot away from challenger_hwk on FIBSUM. :)

(Tjandra Satria Gunawan)(曾毅昆): 2013-08-11 23:24:55

@Dominique VAILLANT: Thanks, Good luck, hope you success to achieve 34B :-)
@Mostafa 36a2 (Al3ayesh): Thanks, I just follow my intuition :-)

Dominique VAILLANT: 2013-08-11 12:55:22

@Tjandra : Congratulations for this amazing result and also for your very interesting spoj blog!!
@Mitch: Congratulations!!
@Mitch+Mostafa+Tjandra: I'm now working very hard in attempting to get 34...

Last edit: 2013-08-11 13:04:21
Mostafa 36a2: 2013-08-11 12:24:23

@Mitch : Congratulations :)
@Tjandra : Congrats on your first AWK code !! amazing :)
@Dominique VAILLANT : Thanks man :)

Dominique VAILLANT: 2013-08-10 18:15:37

@Mostafa: congratulations!!!(x2!! in a short time)
@Mitch: congratulations for your very motivating scores
for many problems!! Thank you for prompting me to gain 1 byte
in Ruby (cf your post 2013-05-25 08:57:34), this now have
tremendous consequences on my scores for many challenge problems.
@Mostafa+@Mitch: I fully agree with Mostafa "Never... never give up!"

Mitch Schwartz: 2013-08-09 17:41:57

@Mostafa: Congrats again. :) I tried several ideas on this one and didn't get an improvement, but at least one of the ideas carried over to FIBSUM.


Added by:Better late than never !!!
Date:2012-06-20
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:RamjiLal Sir