public static double factorial(int n) {double d = 1;if (n >= 0) {if (n <= 170) {for (int i=1; i<=n; i++) {d *= i;}}else {d = Double.POSITIVE_INFINITY;}}else {d = Double.NaN;}return d;}

public static double Factorial(int n){double d = 1;if (n >= 0){if (n <= 170){for (int i = 1; i <= n; i++){d *= i;}}else{d = double.PositiveInfinity;}}else{d = double.NaN;}return d;}
