ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1068. Sum

Accepted C#
Posted by Developer 14 May 2014 17:53
using System;
using System.Linq;
using System.Text;

namespace Sum
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, p = 0;
            x = int.Parse(Console.ReadLine());

            if (x < 0 && x >= -10000)
            {
                for (int i = x; i <= 1; i++)
                    p += i;
            }
            else if (x > 0 && x <= 10000)
            {
                for (int i = 1; i <= x; i++)
                    p += i;
            }
            else
                p = 1;

            Console.WriteLine(p);

            //Console.ReadKey();
        }
    }
}