Answer the question
In order to leave comments, you need to log in
Why does the program stop at 25?
public class LargestSimpleDivider {
public static void main(String[] args) {
for (long i = 100; i > 0; i--) {
long number = 100;
if (i % 2 == 0 || i % 3 == 0) {
System.out.printf("\nnot like this " + i);
} else if(number % i == 0) {
System.out.printf("\nThe largest simple divider: " + i);
break;
}
}
//System.out.printf("proverka 25: " + 25 % 2 + "\n" + 25 % 3);
}
}
Answer the question
In order to leave comments, you need to log in
It fails this test. It goes through the following if(number % i == 0)
You are looking for the maximum number that is not divisible by 2 and 3 and is a divisor of 100. And then break is triggered, so the program ends at 25.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question