fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. static IEnumerable<int> infinite(int step = 1, int start = 0)
  7. {
  8. while (true)
  9. yield return start += step;
  10. }
  11.  
  12. public static void Main()
  13. {
  14. foreach (var i in infinite(2, 13))
  15. {
  16. if (i > 42)
  17. break;
  18. Console.WriteLine(i);
  19. }
  20. }
  21. }
Success #stdin #stdout 0.04s 23952KB
stdin
Standard input is empty
stdout
15
17
19
21
23
25
27
29
31
33
35
37
39
41