public class Divisors { public static int divisors(int n) { int sqrt = (int) Math.floor(Math.sqrt(n)); for (int x = sqrt;; x--) { if ((n % x) == 0) return x; } } public static void main(String[] args) { int x = divisors(3000); int y = 3000 / x; System.out.println("3000: " + x + " " + y); } }