Given a number N, find the total numbers, less than or equal to N which have at-least one common factor with N other than 1.

**Input:**

The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case consist of an integer N.

**Output:**

For each test case output an integer denoting the count of numbers, less than or equal to N having at-least one common factor between the number and N except 1.

**Constraints:**

1<=T<=100000

1<=N<=1000000

**Example:
Input:**

3

1

6

15

0

4

7

For N=1, there are no numbers satisfying the condition.

For N=6, the 4 numbers having a common factor between them and 6 are : 2, 3, 4 & 6

For N=15, the 7 numbers having a common factor between them and 15 are : 3, 5, 6, 9, 10, 12, 15

Author: whiteman

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

the_coder95 | 465 |

thanuvinu94 | 384 |

ShivayLamba | 256 |

adityasuman2025 | 249 |

PrakharBansal1 | 236 |

the_coder95 | 1691 |

RishabhTanwar1 | 1110 |

thanuvinu94 | 1060 |

samay_kam_hai | 724 |

themanhasnoname | 620 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4897 |

Quandray | 4547 |

Login to report an issue on this page.