factorial method
Returns the factorial of this number (must be a non-negative integer).
5.factorial() // 120
Implementation
int factorial() {
final n = toInt();
if (n < 0) throw ArgumentError('factorial requires a non-negative integer');
if (n == 0 || n == 1) return 1;
var result = 1;
for (var i = 2; i <= n; i++) {
result *= i;
}
return result;
}