Pabl0o0

Untitled

Oct 30th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp3
  8. {
  9. class zadanie3
  10. {
  11. public static void square(int n)
  12. {
  13. int sum = 0;
  14. for (int i = 1; i <= n; i++)
  15. {
  16. sum = sum + (i * i);
  17. }
  18. Console.WriteLine(sum);
  19. }
  20. }
  21. static void Main(string[] args)
  22. {
  23.  
  24. int n;
  25. n = int.Parse(Console.ReadLine());
  26. if (n < 0)
  27. {
  28. Console.WriteLine("n musi byc nieujemne");
  29. Environment.Exit(0);
  30. }
  31. else
  32. {
  33. square(n);
  34. }
  35.  
  36. }
  37. }//tutaj zrobić funkcje
Advertisement
Add Comment
Please, Sign In to add comment