0

just found a way to find factorial without recursion

//just found a way to find factorial without recursion static int fact(int x) { int temp = 1, val=x; for (int i = 1; i < val; i++) { x=x * (temp); temp++; } return x; } static void Main(string[] args) { Console.WriteLine( fact(0)); }

11th Feb 2017, 11:23 PM
Shawon
Shawon - avatar
1 Odpowiedź
+ 10
Are you sure fact(0) will return 1?
12th Feb 2017, 12:21 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar