+ 1

having a problem with an algorithm

I got a problem where i get as an input array of numbers (a[]), and have to find numbers which, when used as divisors on an array (a[]), produce a prime number. The problem is that divisors have to be unique so, for instance 10 8 15 7 (array a[]) 2 2 5 7 (output) where: 10 / 5 = 2; 8 / 4 = 2; 15 / 3 = 5; 7 / 1 = 7;

23rd Dec 2017, 9:45 PM
rick harrison
rick harrison - avatar
3 Answers
24th Dec 2017, 2:00 AM
šŸ™evil octopus
šŸ™evil octopus - avatar
+ 3
fixed it. sorry, hadn't noticed! it's done now
24th Dec 2017, 1:36 PM
šŸ™evil octopus
šŸ™evil octopus - avatar
+ 1
Wait, there's a problem: The divisor must be an original number For 10 8 15 7 i've got 2 2 3 7, and that is the wrong answer because: 10 / 5 = 2 (true) 8 / 4 = 2 (true) 15 / 5 = 3 (true, but the divisor has already been used and it can't be)
24th Dec 2017, 1:02 PM
rick harrison
rick harrison - avatar