+ 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;
3 Réponses
+ 3
here is the solution:
https://code.sololearn.com/c8wyyutTM74W/?ref=app
+ 3
fixed it. sorry, hadn't noticed! it's done now
+ 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)