Tentativo 2 dopo aver chiesto aiuto ai miei amici
This commit is contained in:
parent
c5af8bee6a
commit
b443abbdf5
19
Program.cs
19
Program.cs
@ -5,8 +5,9 @@ class Program
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//dichiarazione e inizializzazione variabili
|
||||
int i, j, num;
|
||||
ulong fattoriale, fattorialePrec, fattorialeSupporto;
|
||||
int num;
|
||||
ulong fattoriale, somma, fattorialePrec, fattorialeSupporto;
|
||||
somma=0;
|
||||
//inizio programma
|
||||
//input e input sanitization
|
||||
do{
|
||||
@ -27,8 +28,15 @@ class Program
|
||||
else{
|
||||
fattoriale=Convert.ToUInt64(num);
|
||||
//ciclo calcolo fattoriale
|
||||
Console.WriteLine(fattoriale);
|
||||
for(i=1; i>num-1; i--){
|
||||
for (int i = 2; i < num; i++){
|
||||
|
||||
// eseguo "fattoriale * i" con una serie di somme
|
||||
for (int j = 0; j < i; j++){
|
||||
somma += fattoriale;
|
||||
}
|
||||
fattoriale = somma; // assegna il risultato della "moltiplicazione" alla variabile fattoriale
|
||||
}
|
||||
/*for(i=1; i>num-1; i--){
|
||||
//calcolo fattoriale
|
||||
Console.WriteLine(fattoriale);
|
||||
Console.WriteLine(i);
|
||||
@ -37,10 +45,9 @@ class Program
|
||||
fattorialePrec=fattoriale;
|
||||
fattoriale=fattorialeSupporto+fattorialePrec;
|
||||
Console.WriteLine(fattoriale);
|
||||
}
|
||||
}*/
|
||||
//fattoriale=fattoriale*Convert.ToUInt64(i);
|
||||
}
|
||||
}
|
||||
//output finale
|
||||
Console.Write("Il fattoriale di " +num);
|
||||
Console.WriteLine(" è " +fattoriale);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("fattoriale_somma")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0069d3f078cae82f4b7d5655a3a2fc1e33fffd20")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c5af8bee6add5fd4b61e1fffe87562d3d712c80f")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("fattoriale_somma")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("fattoriale_somma")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@ -1 +1 @@
|
||||
cfb584da00f8687aea9ca76bb315194fb261d639221e676583a64cade696674d
|
||||
66a3353265c9420f2bd556e0251f61e80f588873e29949abb728f549b15d9ab7
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user