Q When there are two natural numbers A and B, A%B is the remainder of A divided by B. For example, the remainder of 7, 14, 27, 38 divided by three is 1, 2, 0, 2.
After receiving 10 inputs, divide them by 42 and get the rest. Then write a program that prints out how many different values there are. ex input 39 40 41 42 43 44 82 83 84 85 ex output 6
when I complied it cnt is still 0 I dont know why for loop doesnt work plz help //codeline
import java.util.Scanner;
public class Modular3052_1 {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
boolean mod[] = new boolean [42];
int cnt = 0;
for(int i = 0 ; i<10 ; i++) {
mod[sc.nextInt()%42] = true;
if(mod[i])
cnt++;
}
System.out.println(cnt);
}
}