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. tekaTekiTeko(30);
  13. }
  14.  
  15. public static void tekaTekiTeko(int max){
  16. if (max < 20) {
  17. throw new IllegalArgumentException("Batas harus >= 20");
  18. }
  19.  
  20. for(int i = 1; i <= max; i++){
  21. String word = "";
  22. if(i % 2 == 0){
  23. word += "Teka";
  24. }
  25. if(i % 3 == 0){
  26. word += "Teki";
  27. }
  28. if(i % 5 == 0){
  29. word += "Teko";
  30. }
  31.  
  32. if(word.length() > 0) {
  33. System.out.println(word);
  34. continue;
  35. }
  36.  
  37. System.out.println(i);
  38. }
  39. }
  40. }
Success #stdin #stdout 0.14s 55308KB
stdin
Standard input is empty
stdout
1
Teka
Teki
Teka
Teko
TekaTeki
7
Teka
Teki
TekaTeko
11
TekaTeki
13
Teka
TekiTeko
Teka
17
TekaTeki
19
TekaTeko
Teki
Teka
23
TekaTeki
Teko
Teka
Teki
Teka
29
TekaTekiTeko