fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes her
  13. int array[] = new int [4];
  14. Scanner sc=new Scanner(System.in);
  15. System.out.print("Enter a number: ");
  16. int x = sc.nextInt(), i=0;
  17. System.out.println(x);
  18. for(int counter=x-1; counter>0; counter--) {
  19. if (counter%3==0 && counter%6==0) {
  20. array[i]=counter;
  21. System.out.println(array[i]);
  22. i++;
  23. if(i==4) {
  24. break;
  25. }
  26. }
  27. }
  28.  
  29. }
  30. }
Success #stdin #stdout 0.14s 35492KB
stdin
50
stdout
Enter a number: 50
48
42
36
30