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!
Select
Add answer anonymously...

Top Software Developer Interview Questions Asked at Protium Finance

Q. Search In Rotated Sorted Array Problem Statement Given a sorted array of distinc...read more
Q. What is the garbage collector in Java?
Q. What is the difference between an abstract class and an interface in Object-Orie...read more
Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits