fork download
  1. package main
  2. import (
  3. "errors"
  4. "fmt"
  5. )
  6.  
  7. func tekaTekiTeko(batas uint) error {
  8. if batas < 20 {
  9. return errors.New("parameter batas harus bernilai minimal 20")
  10. }
  11.  
  12. for i := uint(1); i <= batas; i++ {
  13. output := ""
  14.  
  15. if i%2 == 0 {
  16. output += "Teka"
  17. }
  18. if i%3 == 0 {
  19. output += "Teki"
  20. }
  21. if i%5 == 0 {
  22. output += "Teko"
  23. }
  24.  
  25. if output == "" {
  26. fmt.Println(i)
  27. } else {
  28. fmt.Println(output)
  29. }
  30. }
  31.  
  32. return nil
  33. }
  34.  
  35.  
  36.  
  37. func main(){
  38. if err := tekaTekiTeko(30); err != nil {
  39. fmt.Println("Error:", err)
  40. }
  41. }
Success #stdin #stdout 0s 5320KB
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