write code for Factorial?

Answer Posted / dharmendra nonia

using System;
class Factorial
{
public static void accept()
{
double a;
Console.WriteLine("Enter ur Number:");
a=Double.Parse(Console.ReadLine());
double res=fac(a);
Console.WriteLine(res);
}
public static double fac(double d)
{
if (d == 1)
return 1;
else
return d * fac(d - 1);
}
public static void Main()
{
accept();
Console.Read();
}
}

Is This Answer Correct ?    8 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What benefit do you get from using a primary interop assembly (pia)?

515


What are the uses of delegates in c#?

584


What is wcf c#?

520


What is the default value of decimal in c#?

496


Is array reference type in c#?

490






Difference between value and reference type. What are value types and reference types?

508


How does substring work in c#?

482


Can we call server-side code (c# or vb.net code) from javascript?

525


Can you create partial delegates and enumerations?

583


What is the difference between string and stringbuilder in c#?

473


Why do we need constructor?

492


What is the class in c#?

493


What is the root element of an xml file?

500


Are tuples immutable c#?

508


What you mean by delegate in c#?

498