Seeds of a number
Submissions: 935   Accuracy:

28.7%

  Difficulty: Easy   Marks: 2

A Seed of a number n is a number x such that multiplication of x with its digits is equal to n. The task is to find all seeds of a given number n. x should not be equal to n. If no seed exists, then print -1.

Examples:

Input  : n = 138
Output : 23 
23 is a seed of 138 because
23*2*3 is equal to 138

Input : n = 4977
Output : 79 711 
79 is a seed of 4977 because
79 * 7 * 9 = 4977.
711 is also a seed of 4977 because
711 * 1 * 1 * 7 = 4977


Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains an integer n.

Output:
For each test case in a new line print the space separated values of the seeds in increasing order.

Constraints:
1<=T<=300
1<=n<=1000

Example:
Input:

2
4977
138
Output:
79 711
23

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

Author: Shubham Joshi 1


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.