a task | Sololearn: Learn to code for FREE!

-1

a task

The volunteers are divided into 5 groups with an equal number of people in each. If there are less than 5 people in any group, then in order to restore the number, it is necessary to recruit more volunteers. Write a program that takes the actual number of volunteers as input and prints to the console the number of volunteers that need to be recruited so that there are equal numbers of volunteers across all 5 groups. Sample input 24 Sample output one Explanation The closest number to 24, a multiple of 5 - 25, so we need 1 more volunteer (24 + 1 = 25) so that all 5 groups have an equal number. Use modulo division (%). You cannot use conditions and cycles. https://code.sololearn.com/cP2lfCVGlVA5/?ref=app

6/29/2021 7:37:06 AM

RayDallince

11 Answers

New Answer

+1

well, you have posted your attempt ^^ you don't have to use 25, as this is only the task example number ;) % is used to get reminder of whole division... so to get the number of volunteers that are missing, you must output 5 - (volunters_numbers % 5) ;)

+1

where is your code attempt?

+1

we are not free code providers, and you are here to learn... so you must try to code it by yourself, not requesting other to do the task for you ^^ however, if you provide your code attempt, then we could guide you to complete the task by yourself ;P

+1

Yes, visph is right. You should first try and solve your task by yourself. If you get stuck and really need someone’s help, then only ask for help.

0

yes I tried, it seems simple, but how exactly I don’t know

0

you have deleted your answer to my first post where you said "there's no it"... and now you say you tried, but still not providind your code attempt ^^

0

I meant I didn't save the code.

0

visph Seems to me he just wants the answer😑

0

yes, to understand how this could be solved using only (%)

0

how could I not have thought of (. thanks.

0

function main() { var numberVolunteers = parseInt(readLine(), 10) var x = (numberVolunteers % 5); var y = (numberVolunteers % 5 == 0) ? 0 : 5 - x; console.log(y); }