first commit
This commit is contained in:
27
listas3/source/exercicio2.cs
Normal file
27
listas3/source/exercicio2.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
|
||||
namespace exercicios
|
||||
{
|
||||
class Exercicio2{
|
||||
public static void Init()
|
||||
{
|
||||
int n;
|
||||
Console.WriteLine("Insert a value");
|
||||
n = int.Parse(Console.ReadLine());
|
||||
|
||||
Console.WriteLine("{0}! = {1}",n,calcularFatorial(n));
|
||||
|
||||
}
|
||||
static int calcularFatorial(int n)
|
||||
{
|
||||
int fat = 1;
|
||||
|
||||
for(int i = 1; i <= n; i++)
|
||||
{
|
||||
fat *= i;
|
||||
}
|
||||
|
||||
return fat;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user