Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- class SequenceDec
- {
- private static void Main()
- {
- int n = 0;
- Console.WriteLine("Point out how many members of the sequence you'd like to be displayed below: ");
- string input = Console.ReadLine();
- bool wrongInput = !int.TryParse(input, out n);
- if (wrongInput)
- {
- Console.WriteLine("Sorry pal! Either you cannot differ number from anything else, or you are trying to bug my program :) Well, you can try again later !!!");
- }
- else
- {
- int a = 2;
- while (true)
- {
- wrongInput = a <= n + 1;
- if (!wrongInput)
- {
- break;
- }
- int evenOdd = a % 2;
- wrongInput = evenOdd == 0;
- if (wrongInput)
- {
- Console.Write(string.Concat(a, ", "));
- }
- else
- {
- Console.Write(string.Concat(a * -1, ", "));
- }
- a++;
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement