fork download
  1. import 'dart:io';
  2.  
  3. void main() {
  4. tekaTekiTeko(30);
  5. }
  6.  
  7. void tekaTekiTeko(int batas) {
  8. // tidak boleh negatif
  9. if (batas < 0) {
  10. throw new ArgumentError("Parameter harus unsigned integer (>= 0).");
  11. }
  12.  
  13. // minimal 20
  14. if (batas < 20) {
  15. throw new ArgumentError("Parameter harus bernilai minimal 20.");
  16. }
  17.  
  18. for (int i = 1; i <= batas; i++) {
  19. bool d2 = (i % 2 == 0);
  20. bool d3 = (i % 3 == 0);
  21. bool d5 = (i % 5 == 0);
  22.  
  23. if (d2 && d3 && d5) {
  24. print("TekaTekiTeko");
  25. } else if (d2 && d3) {
  26. print("TekaTeki");
  27. } else if (d2 && d5) {
  28. print("TekaTeko");
  29. } else if (d3 && d5) {
  30. print("TekiTeko");
  31. } else if (d2) {
  32. print("Teka");
  33. } else if (d3) {
  34. print("Teki");
  35. } else if (d5) {
  36. print("Teko");
  37. } else {
  38. print(i);
  39. }
  40. }
  41. }
  42.  
Success #stdin #stdout 1.64s 131020KB
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