Answer to Question #57820 in Java | JSP | JSF for Nithya

Question #57820
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);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS