Least Prime Factor
Submissions: 2623   Accuracy:

54.48%

  Difficulty: Easy   Marks: 2

Given a number N, print least prime factors for all numbers from 1 to N.  The least prime factor of an integer N is the smallest prime number that divides it. The least prime factor of all even numbers is 2. A prime number is its own least prime factor (as well as its own greatest prime factor).  Note : 1 needs to be printed for 1.

Input: N = 6
Output: 1 2 3 2 5 2

The first line of input contains an integer T denoting the number of test cases.
The first line of each test case is N.

Output:
Print least prime factors separated by space


Constraints:
1 ≤ T ≤ 200
2 ≤ N ≤ 1000

Example:
Input:
2
6
10

Output:
1 2 3 2 5 2
1 2 3 2 5 2 7 2 3 2

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: kartik


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.