Divisor of Composite number

Finding divisors of an integer is common task. We all did it in some time or other during our programming courses. We know that there are several ways to find divisors of an integer N . All of them involve some kind of programming using loops. But what if we ask you to solve the reverse problem?

Given all the proper (all the divisors except 1 and N ) positive divisors of a positive composite integer N, you need to find the value of N .

i think the answer will be LCM of all the divisors.

1 Like

multiply smallest and largest value, you will get the answer

3 Likes

lcm will fail in case of divisors of 4 { 1,2 ,4 }

No, LCM will give answer 4. If it is not correct then what will be the answer of {1,2,4} and how?

In case of {1,3,7} if you multiply largest and smallest value you will get 7.
But the answer should be 21.

The proper divisors of 21 are 3 and 7, and multiplying them gives 21.

Similarly, the proper divisors of 4 is just \{2\}, and multiplying the lowest of these (2) by the highest (2 again XD) gives 4.

What is the source of the question? I hope its not from an ongoing contest.

3 Likes

What about 42{2,3,7} ?
Multiplying smallest and largest number will give answer 14 but the answer should be 42.

1 Like

Proper divisors of 42 are \{2,3,6,7,14,21\} (I think), and the smallest (2) times the largest (21) is 42.

1 Like

Then what will be the answer of {2,3,7} ?

I’m not sure there is such a number - if it’s divisible by 2 and 3 and is strictly greater than 7, it will also be divisible by 6.

2 Likes

Maybe you are correct , I thought that the divisors which are input will always be prime.

No its not from any ongoing contest on CodeChef

this seemed similar to Atcoder ABC 142’s D question
(D - Disjoint Set of Common Divisors)
Plus you kind of phrased that it’s not from any ongoing contest on codechef