Skip to content

Instantly share code, notes, and snippets.

@kodamirmo
Created April 29, 2013 00:15
Show Gist options
  • Save kodamirmo/5478986 to your computer and use it in GitHub Desktop.
Save kodamirmo/5478986 to your computer and use it in GitHub Desktop.
Segunda clase factorial
using System;
namespace HolaMundo
{
public class CalculaFacorial
{
public int calcularFacorial (int numero)
{
int facorial=1;
try{
if(numero==0 || numero==1)
return 1;
for (int i=1; i<=numero; i++) {
facorial=facorial*i;
}
return facorial;
}
catch (OverflowException e)
{
Console.WriteLine(e.Message);
return 1;
}catch (NotFiniteNumberException e)
{
Console.WriteLine(e.Message);
return 1;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment