fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. Console.WriteLine("Введите число");
  8. int x=Convert.ToInt16(Console.ReadLine());
  9. int y=0;
  10. int z=0;
  11. Console.WriteLine(x);
  12. while(++y<=x)
  13. {
  14. z=y+z;
  15. }
  16. Console.WriteLine("Сумма всех чисел от 1 до {0}={1}",x,z);
  17. }
  18.  
  19. }
Success #stdin #stdout 0.01s 131776KB
stdin
5
stdout
Введите число
5
Сумма всех чисел от 1 до 5=15