P16211 [GeeksforGeeks] Composite series1258
普及-
题目描述

Given a number N, print all the composite numbers less than or equal to N. The number should be printed in ascending order.
Example 1:
Input: N = 10
Output: 4, 6, 8, 9, 10
Explaination: From 1 to 10 these are
the only composite numbers.
Example 2:
Input: N = 6
Output: 4, 6
Explaination: From 1 to 6 these are
the only composite numbers.
Your Task:
You do not need to read input or print anything. Your task is to complete the function compositeNumbers() which takes N as input parameters and returns a list containing all the composite numbers from 1 to N.
Expected Time Complexity: O(N* sqrt(N))
Expected Auxiliary Space: O(N)
Constraints:
4 ≤ N ≤ 10^{4}

输入格式

见题面

输出格式

见题面

样例输入
N = 10
样例输出
4, 6, 8, 9, 10