Working with Factors


Submit solution

Points: 10 (partial)
Time limit: 8.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Python

Problem Definition

Given a collection of N unique numbers, do the following tasks as a menu-driven Program.

  1. Print the factors of a selected number, if it is present. If the selected number is not in the collection, print the message "Error"
  2. Out of the factors of all N numbers, print the unique factors. A unique factor is the number which appears as a factor of only one out of the N numbers.

Input Format

The first input is the number of elements, N.

The next N inputs are the numbers. Ensure that out of N numbers inputted, no duplicates should be stored.

The next input is the choice of operation - 1 or 2. If this input is 1, the next input will be the number for which the factors are to be printed.

Output Format

For option 1, the factors are printed for the selected number on the same line separated by a single space, if it is present in the collection. If the selected number is not present in the collection, it will print the message "Error".

Option 2, prints the factor that occurs only once out of all the factors of N numbers, in the same line separated by a single space.

If the option is neither 1 nor 2, a message "Error" is printed as output.

Sample Input1

3

49

15

7

1

15

Sample Output1

1 3 5 15

Sample Input2

3

49

15

7

2

Sample Output1

49 3 5 15


Comments

There are no comments at the moment.