Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace lab_2._1
- {
- class Program
- {
- static void Main(string[] args)
- {
- //case1
- int n, sum1, sum = 0;
- Console.WriteLine("Input n");
- n = Convert.ToInt32(Console.ReadLine());
- for(int i = 1; i<=n; i++ )
- {
- sum += (int)Math.Pow(i, 2);
- //Console.WriteLine(sum); uncomment to check iterations
- }
- //case2
- sum1 = (n * (n + 1) * (2 * n + 1)) / 6;
- if(sum==sum1)
- {
- Console.WriteLine("Formule is right");
- }
- else
- {
- Console.WriteLine("Formule isn't right");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement