Prime Factorization Problem Statement

Given several queries each containing a single integer 'N', the task is to find the prime factorization of each integer using a sieve method.

Example:

Input:
N = 12
Output:
2 2 3

Input:

The first line contains a single integer ‘T’, representing the number of test cases.
The first line of each test case contains a single integer 'Q', representing the number of queries.
The second line of each test case will contain 'Q' space-separated integers, representing the integers whose prime factorization you have to find.

Output:

For each test case, print all the prime factors of 'N' in a single line separated by a single space. 
Output for each query will be printed in a separate line.
The order of the output for each query doesn't matter.
Output for each test case will be printed in a separate line.

Constraints:

  • 1 <= T <= 5
  • 1 <= Q <= 10^5
  • 2 <= N <= 10^6
  • Time Limit: 1 sec.
Note
You are not required to print anything; it has already been taken care of. Just implement the function and return the answer. 
AnswerBot
1y

The task is to find the prime factorization of given integers using a sieve.

  • Implement a function to find the prime factors of each integer using a sieve algorithm.

  • Use the given input format to read th...read more

Help your peers!
Add answer anonymously...
Protium Finance Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter