return array function in C# which displays the factorial in below I have shown

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Muzamil
    New Member
    • Nov 2012
    • 1

    return array function in C# which displays the factorial in below I have shown

    What I'm making mistake I want to display in such a way
    Enter the number : 4
    Factorial of 4 is : 1x2x3x4 = 24!


    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Factorial
    {
        class fact
        {
            public int[] factorial(int num)
            {
                int[] fact = new int[10];
                for (int i = 0; i < num; i++)
                {
                    fact[i] = fact[i] + i;
                }
                return fact;
            }
        }
    
        class fact
        {
            static void Main(string[] args)
            {
                fact num1 = new fact();
                int num;
                int[] result;
    
                num = Convert.ToInt32(Console.ReadLine());
    
                result = num1.factorial(num);
                for (int i = 0; i < num; i++)
                {
    
                    Console.Write(result[i]);
    
                    Console.WriteLine();
                    Console.WriteLine();
                }
    
            }
        }
    }
    Last edited by PsychoCoder; Nov 6 '12, 06:21 PM. Reason: Please use code tags when posting your code
Working...