Project Euler #6: Sum square difference

  • + 0 comments

    c# , Could anyone understand why it didn't pass test 1?

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    class Solution {
    
        static void Main(String[] args) {
            int t = Convert.ToInt32(Console.ReadLine());
            for(int a0 = 0; a0 < t; a0++){
                int n = Convert.ToInt32(Console.ReadLine());
                int sonuc = Fonk(n);
                Console.WriteLine(sonuc);
            }
        }
        static int Fonk(int n){
            int sum = 0;
            int sum2 = 0;
            int sonuc = 0;
            
            for(int i = 1; i <= n; i++){
                sum += i;
                sum2 += i * i;
            }
            
            sonuc = sum * sum - sum2;
            return sonuc;
        }
    }