Advertisement
kuruku

PrintSequence

Apr 14th, 2014
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.43 KB | None | 0 0
  1. using System;
  2.  
  3. //Write a program that prints the first 10 members of the sequence: 2, -3, 4, -5, 6, -7, ...
  4.  
  5. class PrintSequence
  6. {
  7.     static void Main()
  8.     {
  9.         for (int i = 2; i < 13; i++)
  10.         {
  11.             if (i % 2 != 0)
  12.             {
  13.                 Console.Write("{0}, ", i * (-1));
  14.             }
  15.             else
  16.             {
  17.                 Console.Write("{0}, ", i);
  18.             }
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement