Write a program that asks the user to input an integer, n, and finds and print the largest number divisible by n that is made from the product of two 3-‐‐digit numbers.
1
Expert's answer
2016-02-16T03:04:53-0500
public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int res = 0; for(int i = 0; i<1000000; i++){ if(i%n==0){ for(int j = 100; j<1000; j++){ if(i%j == 0 && ((i/j)>=100 && (i/j)<1000)){ res = i; } } } } System.out.println(res); }
Comments
Leave a comment