Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

Little stuart and his teacher HackerEarth

$
0
0

Little Stuart is a smart guy, and he loves mathematics. Today his math teacher taught his class about common factors. After finishing the class his teacher asked them a question: For a given number "n" calculate the number of unordered pairs (a,b) which have at least one common factor where 1 <= a < b <= n .

Note: 1 is not considered as common factor.

Input : First line contain the number of test cases "t" Next "t" lines contain a number "n"

Input Constraints:

1<=T<=100000

1<=n<=1000000

Output: For each case print total number of pairs. Sample Input 3 1 2 5

Sample output 0 0 1

Explanation For testcase - 3 ,

N = 5

Some possible pairs = [(1, 2), (2, 3), (2, 4), (3, 4), (4, 5)]

The only pair which has common factor is (2, 4). So the answer is 1 for N = 5.

Note: 1 is not considered as common factor. Time Limit 1 sec(s) Memory Limit 256 MB Source Limit 1024 KB


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>