+ 1

I still fail test case 3 in "divisible by all" challenge.Does anyone know why?Here is my code

import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String a=sc.nextLine(); String b=sc.nextLine(); String[]b1=b.split(" "); int co=0; int[] arr = new int[b1.length]; for (int i = 0; i < b1.length; i++) { arr[i] = Integer.parseInt(b1[i]); } int x=Integer.parseInt(a); for(int j=0;j<arr.length;j++){ if(x%arr[j]==0){ co+=1; } } if(co==arr.length){ System.out.println("divisible by all"); }else{ System.out.println("not divisible by all"); } } }

26th Dec 2022, 1:03 PM
Killiam Chances
Killiam Chances - avatar
3 Respostas
+ 1
Recheck output statements spell check with case sensitivity.. can you add problem description or link..?
26th Dec 2022, 2:07 PM
Jayakrishna 🇮🇳
+ 1
Here is description You need to know if a number is divisible by each of a group of other numbers. If you are given the number and the group of other numbers, you will test to make sure that it is divisible by all of them. Task: Test your number against all of the other numbers that you are given to make sure that it is divisible by them. Input Format: Two inputs: an integer value (the number you are testing) and a string of variable length of the integers that you should test against separated by spaces. Output Format: A string that says 'divisible by all' or 'not divisible by all'. Sample Input: 100 2 5 10 Sample Output: divisible by all
27th Dec 2022, 9:39 AM
Killiam Chances
Killiam Chances - avatar
+ 1
Is there any other thing to consider? Like what if input have 0 in divisors.. Can you add task number and course name, if still have problem, so that i can try to test this..!
27th Dec 2022, 10:34 AM
Jayakrishna 🇮🇳