+ 2
Need help with what logical operators to use. I've used the modular but it only passed 1 case.
Volunteers have been divided into 5 groups with equal number of members. If any group has fewer than 5 people, more volunteers must be recruited to fill the positions. Write a program that takes the number of volunteers and outputs to the console how many volunteers need to be hired to have 5 equal groups. Sample Input 24 Sample Output 1 Explanation The nearest number to 24 that is multiple of 5 is 25, so we need 1 more volunteer (24+1=25) to get 5 equal groups.
7 Respuestas
+ 6
if volunteers % 5 results in remainder zero ,then all volunteers got divided equally in 5 groups 
If remainder is not 0 ,then 5-remainder will tell you how many extra volunteers are needed
+ 5
+ 4
function main() {
    var numberVolunteers = parseInt(readLine(), 10)
// find the remainder of Volunteers when you divide them by 5
    var remainder = numberVolunteers % 5
// if it's equal to 0 print 0, if it's not equal to 0 print the result of subtract the remainder from 5
    result = (remainder == 0) ? console.log(0) : console.log(5 - remainder)
}
+ 4
//another solution by if 
function main() {
    var numberVolunteers = parseInt(readLine(), 10)
    var remainder = numberVolunteers % 5
    if( remainder == 0){
        console.log(0)
    }
    else{
        console.log(5 - remainder)
    }
}
+ 2
Thank you Abhay! I figured it out once you wrote it out in a way I could fully understand.
+ 1
I've done exactly this but it's still not accepted.
+ 1
If any group has fewer than 5 people, more volunteers must be recruited...? 
Isnt this setting a min of 5 groups of 5?
One of the tests is input of 14, with expected output of 1.
Poorly worded question or?



