Advertisement
svetlozar_kirkov

Print Long Sequence (Homework)

Oct 19th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using System;
  2.  
  3. namespace PrintLongSequence
  4. {
  5.     class PrintLongSequence
  6.     {
  7.         static void Main()
  8.         {
  9.             int x = 2;
  10.             for (int i = 0; i < 1000; i++)
  11.             {
  12.                 if (i < 999)
  13.                 {
  14.                     Console.Write(x + ", ");
  15.                     if (i % 2 == 0)
  16.                     {
  17.                         x = -x;
  18.                         x--;
  19.                     }
  20.                     else
  21.                     {
  22.                         x = -x;
  23.                         x++;
  24.                     }
  25.                 }
  26.                 else
  27.                 {
  28.                     Console.WriteLine(x);
  29.                 }
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement