Reference no: EM13161155
One commonly used method to calculate all primes in the range [2..n] is to start with the number 2, mark it as prime, and mark all its multiples (excluding itself) as not prime. Then, we find the next smallest unmarked number, mark it as prime, and mark all its multiples (excluding itself) as not prime. Continuing this way, we get a list of all primes.
Now, let us say that we modified the above algorithm, and start with n instead of 2. We mark it as prime, and mark all its factors (excluding itself) as not prime. Then we find the next greatest unmarked number, mark it as prime, and mark all its factors (excluding itself) as not prime. Continuing this way, we get a list of all primes.
Now you wonder, given a value of n, how many numbers are such that both the above algorithms will mark them as prime?
Input
The first line contains T the number of test cases. Each of the next T lines contain an integer n.
Output
Output T lines, one for each test case, containing the required answer.
Example
Sample Input :
3
2
4
7
Sample Output :
1
1
2
Constraints
1 <= T <= 100000
2 <= n <= 10000000
Write c++ program that reads in the average monthly rainfall
: Write a C++ program that reads in the average monthly rainfall for a city for each month of the year and then reads in the actual monthly rainfall for each of the previous 12 months
|
State and draw the six conformers in newman projection
: Draw the six conformers in newman projection for the 60 degree intervals from 0 to 360 degrees for carbon atoms 3 and 4. Clearly show which carbon is represented by the "dot" and the "circle" Show which C
|
Hidden implementations are often said
: Hidden implementations are often said to exist in a black box. Do you agree with this statement? Why or why not? Identify the advantages and disadvantages of using this approach in both programming and real life?
|
Compute the work done
: A coffee cup calorimeter is being used in this lab despite the fact that one of the reactions produces gas. Calculate the work done using the information
|
Method to calculate all primes in the range [2..n]
: One commonly used method to calculate all primes in the range [2..n] is to start with the number 2, mark it as prime, and mark all its multiples (excluding itself) as not prime. Then, we find the next smallest unmarked number, mark it as prime, and m..
|
To simplify the problem, the values can each be placed
: Use Notepad to place the following value in a text file: 86, 97, 144, 26. To simplify the problem, the values can each be placed on separate lines
|
Explain obtain the positions of the wavefunctions nodes
: obtain the positions of the wavefunctions nodes from the roots of the corresponding Hermite polynomial, and (d) from your answers to (b) and (c), sketch the wave functions, indicating nodes and boundary conditions behaviors at +/- infinite in the ..
|
Generated by some condition that occurs as a result
: Program: Generated by some condition that occurs as a result of an instruction execution, such as arithmetic overflow, division by zero, attempt to execute an illegal machine instruction, and reference outside a user's allowed memory space.
|
The arrangement of a group of variables along a grid
: a two-dimensional array is nothing more than the arrangement of a group of variables along a grid. Each variable occupies a specific row and column
|