help-rachit-2

Rachit, one of the best programmers of Geekland university is busy in his research on prime numbers these days. Once, while roaming in the campus he saw numbers written in a spiral and he observed that  many prime numbers occur on both the diagonals as shown in figure below (Yes,he is a brilliant observer).

37 36 35 34 33 32 31
38 17 16 15 14 13 30
39 18  5  4  3 12 29
40 19  6  1  2 11 28
41 20  7  8  9 10 27
42 21 22 23 24 25 26
43 44 45 46 47 48 49

He is very curious to know what percentage of prime numbers is there on both the diagonals to that to all the numbers on the diagonal. your task is to write a program to help rachit.

NOTE: Value of n is always going to be odd.

Input:

First line of input contains an integer t, which is the number of test cases. t lines follow, with each test containing an integer which is the size of spiral matrix (Size of above matrix is 7).

Output: 
For each test case output a single line which is the percentage of number of prime numbers on the diagonal to the total numbers on diagonal, correct to six decimal places.

Constraints :

 1 ≤ t ≤ 10^5

sz is any odd value between 3 and 10^4

SAMPLE INPUT
1
7

SAMPLE OUTPUT
61.538462

Explanation

The above spiral represents the spiral of size 7. 
Numbers on the diagonal are: 37, 17, 5 ,1, 9, 25, 49, 31, 13, 3 ,7, 21, 43
Out of which prime numbers are: 37, 17, 5, 31, 13, 3, 7, 43

61.538462% of total numbers on diagonal are prime numbers.

Source: hackerearth | Difficulty: MEDIUM
Tags: Number theory

Dynamic programming

Mathematics


Solutions: