60 426
Assignments Done
98,1%
Successfully Done
In April 2018

# Answer to Question #12062 in C# for Jenny

Question #12062
Write a program to determine the largest value of n such that your computer can compute n! w/out integer overflow. n! is the product of all positive numbers that are less than or equal to n. For examplem 3! = 1x2x3=6. By convention,0 is set equal to 1.
using System;
using System.Collections.Generic;
using
System.Linq;
using System.Text;

namespace Factorial
{
class
Program
{
static void Main(string[] args)
{
Console.Write(&quot;Enter a
number (&lt; 0 to stop): &quot;);
int num =
while (num &gt;
0)
{
Console.WriteLine(num + &quot;! = &quot; +
factorial(num));
Console.Write(&quot;Enter a number ( &lt;0 to stop): &quot;);
num =
}
}
public
static double factorial(long n)
{
if (n &lt; 1)
return 0;
double
product = 1;
for (int i = 1; i &lt;= n; i++)
product *= i;
return
product;
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!