ahmed0saber

Factorial Calculator in C#

Nov 21st, 2020
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.25 KB | None | 0 0
  1. using System;
  2. namespace Factorial
  3. {
  4. class Project1
  5. {
  6. void Main()
  7. {
  8. int x,f;
  9. Console.Write("Enter a positive number : ");
  10. x=Convert.ToInt32(Console.ReadLine());
  11. f=x;
  12. while((x-1)>0){
  13. f=f*(x-1);
  14. x--;}
  15. Console.Write("The factorial is {0}",f);
  16. }
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment