Advertisement
Guest User

Sequence

a guest
Jun 5th, 2016
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Intro_CSharp
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int x=2;
  14. int y = -3;
  15. Console.Write(x + " ");
  16. Console.Write(y + " ");
  17. int count = 0;
  18. for (int i = 1; i < 99; i++)
  19. {
  20. if (i%2==0)
  21. {
  22. y-= 2;
  23. Console.Write(y+" ");
  24. }
  25. else
  26. {
  27. x += 2;
  28. Console.Write(x+" ");
  29. }
  30. count++;
  31. }
  32. Console.WriteLine();
  33. Console.WriteLine("Total numbers: "+(count+2));
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement