[Solved] c#, non-prime numbers, array, returning, method [closed]


static void Main(string[] args)
{
    int[] array = new int[] { 1, 2, 3, 4, 5, 6, 7,8,9,10,11,12,13,14 };
    List<int> nonprimeNumbers = new List<int>();
    int sumofnonprimenumbers = 0;
    for (int i = 0; i < array.Length; i++)
    {
        if (!IsPrime(array[i]))
        {
            //Console.WriteLine(array[i]);
            nonprimeNumbers.Add(array[i]);
        }
    }
    Console.Write("Non-Prime Numbers:");
    for (int i = 0; i < nonprimeNumbers.Count; i++)
    {
        Console.Write(nonprimeNumbers[i] +" ");
        sumofnonprimenumbers += nonprimeNumbers[i];
    }
    Console.WriteLine("\nSum of non-prime Numbers: "+sumofnonprimenumbers);
    decimal arthmeticmean = sumofnonprimenumbers / nonprimeNumbers.Count;
    Console.WriteLine("Arithmetic mean of non prime numbers " + arthmeticmean); 

}

private static bool IsPrime(int number)
{
    bool value = false;
    int n, m = 0, flag = 0;
    n = number;
    m = n / 2;
    for (int i = 2; i <= m; i++)
    {
        if (n % i == 0)
        {
            flag = 1; // prime number
            break;
        }
    }
    if (flag == 0)
    {
        value = true;
    }
    return value;
}

solved c#, non-prime numbers, array, returning, method [closed]