Whether this example is returning the result via a parameter?

0 like 0 dislike
6 views
The point is that to find the factorial of a given number and display the result via a parameter.
I'm a noob in sharp, please explain if something is done wrong. Thank you!

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CustomMethodsOfClass { class Program { static void Factorial1(int number) { int factorial = 1; for (int i = 1; i <= number; i++) { factorial *= i; if (i == number) { Console.Write("{0}", i); } else { Console.Write("{0} * ", i); } } Console.Write(" = {0}", factorial); Console.ReadKey(); } static void Main(string[] args) { Console.Write("Enter number : "); int number = int.Parse(Console.ReadLine()); Factorial1(number); } } }
by | 6 views

2 Answers

0 like 0 dislike
static void Fact(int number, out int result) { result = 1; while(number!=1) { result *= number; number--; } }
by
0 like 0 dislike
No. See here the second and third headers.
by

Related questions

0 like 0 dislike
4 answers
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
33,713 users