[ ASSIGNMENT: ] Transform To Prime | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 27

[ ASSIGNMENT: ] Transform To Prime

TASK: GivenĀ a List[ ] of n integers, find minimum number to beĀ insertedĀ in aĀ list, so thatĀ sum of all elements of listĀ shouldĀ equal the closest prime number. NOTE! - List sizeĀ isĀ at least 2. - List's numbersĀ will onlyĀ positivesĀ (n > 0). - RepeatitionĀ of numbers in the listĀ could occur. - The newer list's sumĀ shouldĀ equal the closest prime number. Example #1 minimumNumber({3, 1, 2}) --> return (1) Explanation: Since,Ā the sumĀ of the list's elements equal toĀ (6), the minimum number to be inserted to transform the sum to prime numberĀ isĀ (1), which will make the sum of the ListĀ equal the closest prime numberĀ (7). Example #2 minimumNumber({2,12,8,4,6})-->return (5) Explanation: Since,Ā the sumĀ of the list's elements equal toĀ (32), the minimum number to be inserted to transform the sum to prime numberĀ isĀ (5), which will make the sum of the ListĀ equal the closest prime number (37). HappyCodings!:) https://code.sololearn.com/WBTmxnVI7fYR/?ref=app

2nd Jun 2018, 9:28 AM
Danijel Ivanović
Danijel Ivanović - avatar
11 Respostas
+ 30
https://code.sololearn.com/cLtmg5vCgTlc/?ref=app
2nd Jun 2018, 10:23 AM
šŸŒ›DTšŸŒœ
šŸŒ›DTšŸŒœ - avatar
21st Jul 2018, 3:07 PM
Sumit ProgrammeršŸ˜ŽšŸ˜Ž
Sumit ProgrammeršŸ˜ŽšŸ˜Ž - avatar
+ 14
https://code.sololearn.com/cms8h3A5rx0U/?ref=app
4th Jun 2018, 5:44 AM
LukArToDo
LukArToDo - avatar
+ 6
my try, not very efficient though edit : working properly https://code.sololearn.com/cCpq9jo2u6gl/?ref=app
2nd Jun 2018, 11:14 AM
ā€ŽĀ ā€ā€ā€ŽAnonymous Guy
+ 6
https://code.sololearn.com/cjDibidYXl79/?ref=app
2nd Jun 2018, 10:46 PM
reviiea
reviiea - avatar
4th Jun 2018, 2:46 PM
Francisco Casas
Francisco Casas - avatar
+ 3
https://code.sololearn.com/cg814zFgVQ7J/?ref=app
2nd Jun 2018, 10:47 PM
VcC
VcC - avatar
+ 3
Hii Danijel Ivanović this is my try in Kotlin = https://code.sololearn.com/cCMS3dd0WXn8/?ref=app
12th Jul 2018, 8:50 AM
Salman
Salman - avatar
+ 2
hi, no one-liners! here is one: https://code.sololearn.com/cp4N5GdNxu0i/?ref=app whereā€™s ur submission btw, Danijel Ivanović ?
6th Jul 2018, 12:18 PM
Flash