Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace negyzetsum
- {
- class Program
- {
- static void Osszeg(int n)
- {
- int i, osszeg = 0;
- if (n <= 1)
- {
- Console.WriteLine("1-től nagyobb számot kell bevinni \n");
- return;
- }
- for (i = 1; i <= n; ++i)
- {
- osszeg += i * i;
- }
- System.Console.WriteLine("A számok négyzetének összege 1-től {0}-ig {1}\n", n, osszeg);
- }
- static void Main(string[] args)
- {
- int x;
- Console.Write("Írd be a számot, amelyig össze akarod adni a négyzeteket: ");
- x = int.Parse(Console.ReadLine());
- Osszeg(x);
- Console.WriteLine("Kólity Kristóf");
- Console.WriteLine("Enter nyomásával újraindítható a program.");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement