fork download
  1. <?php
  2.  
  3. // your code goes here
  4. function tekaTekiTeko(int $batas) {
  5. if ($batas < 20) {
  6. throw new Exception("Batas harus merupakan unsigned integer mulai dari 20");
  7. }
  8.  
  9. for ($x = 1; $x <= $batas; $x++) {
  10. $output = '';
  11. if ($x % 2 == 0) {
  12. $output .= 'Teka';
  13. }
  14. if ($x % 3 == 0) {
  15. $output .= 'Teki';
  16. }
  17. if ($x % 5 == 0) {
  18. $output .= 'Teko';
  19. }
  20. if ($output == '') {
  21. echo $x . "\n";
  22. } else {
  23. echo $output . "\n";
  24. }
  25. }
  26. }
  27.  
  28. tekaTekiTeko(30);
Success #stdin #stdout 0.02s 26024KB
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