10 AnswersNew Answer
Add ,trim() to nextLine() it's added in my code now https://www.sololearn.com/discuss/2172728/?ref=app
Piyush Srivastava The parsing is to convert the input type from its default of String to int. This is correct and necessary in order to do the mathematical calculations without having a type error. The split is needed as well. The second input is a space separated string of numbers so they also need to be converted after being split into an array which is iterated over to check if each number in the array is a factor of the first number input.
Thanks, 3rd case has space in the first input. nextInt trims it automatically, but Integer.parseInt doesn't.
I don't have pro, but my guess would be that you are missing a use case. Without knowing the challenge definition I can only speculate. I'm guessing that you are being given a 0 as a possible divisor and thus are receiving a divide by zero error. I modified your code to reduce it and added a return false for a 0 (again reread the challenge definition and make sure you are covering all possible use cases). https://code.sololearn.com/ccCLGZUuQM5H/?ref=app edit: fixed my error in code. whoops forgot to test it prior to posting. lol
Divide by zero has been handled in my code
3rd case has a bug: it doesn't pass neither "divisible by all", nor "not divisible by all". https://code.sololearn.com/c0V2m0mMzwiV/?ref=app
It's a bad idea using nextLine on single integer inputs, unless the input is a row of integer values separated by spaces.
ChaoticDawg Testcase #3 still not passed after I tried your suggestion
May be, if input contains 0, then it raise exception so it need to handled as special case.. By try catch.. If you still, don't get that way, then try to put description here.. That may help to analize the program correctly..
There is no bugs in any of the test cases. My code didn't have any problems. https://code.sololearn.com/cLIyqexxa3Yo/?ref=app