You are given an integer 'N'.
You must return the unique prime factors of 'N' in increasing order.
For ‘N’ = 10.
Unique prime factors are 2 and 5.
Hence we return {2, 5}.
The only line contains a single integer 'N'.
Output Format:
The only lines contain the unique prime factors of 'N'.
Note:
You are not required to print anything; it has already been handled. Just implement the function.
35
5 7
Unique prime factors are 5 and 7.
Hence we return {5, 7}.
14
2 7
1 <= 'N' <= 10^6
Time Limit: 1 sec.
Try to use sieve of Eratosthenes.
Approach:
O(Nlog(log(N))), where ‘N’ is the given number.
We are using the Sieve of Eratosthenes, so our complexity is O(Nlog(log(N))).
O(N), where ‘N’ is the given number.
We are creating an array/vector of size ‘N’, so the space complexity is O(N).