Changes from Version 1 of FactorialExample2
- Timestamp:
- 04/17/10 03:42:29 (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
FactorialExample2
v0 v1 1 2 {{{ 3 /* 4 * Factorial using recursive method 5 */ 6 import std.stdio; 7 8 real factorial(uint i) { 9 if (i == 0) { 10 return 1; 11 } else { 12 return factorial(i - 1) * i; 13 } 14 } 15 16 int main() 17 { 18 writef("Enter an unsigned int: "); 19 uint i = 0; 20 21 scanf("%u", &i); 22 23 writefln(factorial(i)); 24 25 return 0; 26 } 27 }}}