Unreachable Code

spark Reply 4 years 49 weeks ago
public static void findNum(int number) { ArrayList<Integer> smallestFactorial = new ArrayList<Integer>(); boolean fin = false; while (true) { for (int i = 2; i <= number; i++) { if (isPrime(i)) { while (number % i == 0) { smallestFactorial.add(i); } } } } System.out.println("hello"); }
withcs2 Reply 4 years 49 weeks ago
why don't you use the variable "fin"? "while(true)" loops infinitely.
spark Reply 4 years 49 weeks ago
while (number % i == 0) { number /= i; smallestFactorial.add(i); } it is still unreachable code.
withcs2 Reply 4 years 49 weeks ago
you must break "while (true)"