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. int totalDivisiveis = 0;
  13.  
  14. System.out.println("Diviseis por 3:");
  15.  
  16. for(int i = 1; i <= 100; i++){
  17. if(i % 3 == 0){
  18. System.out.print(i + " ");
  19. totalDivisiveis++;
  20. }
  21. }
  22. System.out.println();
  23. System.out.println("Total: " + totalDivisiveis);
  24.  
  25. }
  26. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
Diviseis por 3:
3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99 
Total: 33