Advertisement
adriyanbulgary

Untitled

May 29th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. using System;
  2. /*
  3.  * Write a program that prints the first 1000 members of the sequence: 2, -3, 4, -5, 6, -7, …
  4.  * You might need to learn how to use loops in C# (search in Internet).
  5.  */
  6. class PrintLongSequence
  7. {
  8.     static void Main()
  9.     {
  10.         int i = 2;
  11.         for (int j = 0; j < 1000; j++)
  12.         {
  13.             if (i % 2 == 0)
  14.             {
  15.                 Console.Write(i + "\t");
  16.                 i++;
  17.                 continue;
  18.             }
  19.             Console.Write(-i + "\t");
  20.             i++;
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement