P21719 [GeeksforGeeks] Mathematical manipulation2005
普及
题目描述

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.

Example 1:
Input: n = 6
Output: 4
Explanation: For n=6, the 4 numbers having
a common factor between them and 6
are : 2, 3, 4 & 6
Example 2:
Input: n = 15
Output: 7
Explanation: For N=15, the 7 numbers having a
common factor between them and 15
are : 3, 5, 6, 9, 10, 12, 15

Your Task:
You don't need to read or print anything. Your task is to complete the function CommonFactor() which takes n as input parameter and returns total numbers. less than or equal to n which have atleast one common factor with n other than 1.

Expected Time Complexity: O(nlog(n))
Expected Space Complexity: O(n)
Constraints:
1 <= n <= 10^{5}

输入格式

见题面

输出格式

见题面

样例输入
n = 6
样例输出
4