factorial method
Returns the factorial of this int.
This is the number of ways to arrange n
distinct objects into a
sequence.
Implementation
int factorial() {
if (this < 0) {
throw ArgumentError('$this.factorial() is undefined.');
}
if (this < factorials.length) {
return factorials[this];
}
var r = factorials.last;
for (var i = factorials.length; i <= this; i++) {
r *= i;
}
return r;
}