fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. Console.Write("Masukan Batas Looping : ");
  8. try
  9. {
  10. int batas = Convert.ToInt32(Console.ReadLine());
  11. if (batas < 20)
  12. {
  13. Console.WriteLine("Batas harus lebih besar dari 20");
  14. return;
  15. }
  16. for (int i = 1; i <= batas; i++)
  17. {
  18. string output = "";
  19.  
  20. if (i % 2 == 0) output += "Teka";
  21. if (i % 3 == 0) output += "Teki";
  22. if (i % 5 == 0) output += "Teko";
  23.  
  24. Console.WriteLine(string.IsNullOrEmpty(output) ? i.ToString() : output);
  25. }
  26. }
  27. catch (Exception ex)
  28. {
  29. Console.WriteLine("Terjadi kesalahan, hanya bisa inputkan angka: " + ex.Message);
  30. }
  31. }
  32. }
  33.  
Success #stdin #stdout 0.06s 30480KB
stdin
20
stdout
Masukan Batas Looping : 1
Teka
Teki
Teka
Teko
TekaTeki
7
Teka
Teki
TekaTeko
11
TekaTeki
13
Teka
TekiTeko
Teka
17
TekaTeki
19
TekaTeko