|
|
back to boardDiscussion of Problem 1068. SumWhy dont work?C# Posted by Artem 2 Feb 2018 13:12 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication25 { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()), Sum=0; if (Math.Abs(N)<10000) { while (N != 1) { if (N > 1) { Sum = Sum + N; N--; } else { Sum = Sum + N; N++; } } } Console.WriteLine(Sum+1); } } } |
|
|