galinyotsev123

ProgBasicsJavaBook7.2ComplexLoop03stopNumber

Jan 12th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E03stopNumber {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int N = Integer.parseInt(scanner.nextLine());
  8. int M = Integer.parseInt(scanner.nextLine());
  9. int S = Integer.parseInt(scanner.nextLine());
  10.  
  11. for (int i = M; i >= N; i--) {
  12. if(i % 2 == 0 && i % 3 == 0 && i != S){
  13. System.out.printf("%d ", i);
  14. }
  15. else if (i % 2 == 0 && i % 3 == 0 && i == S){
  16. break;
  17. }
  18. }
  19.  
  20.  
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment