import java.util.Scanner;
class Factorial {
public static long factorial(int n) {
long result = 1;
if (n < 0) {
return 1;
}
for (int i = 2; i <= n; i++) {
result *= i;
}
return result;
}
public static void main
(String[] args
) { Scanner scanner
= new Scanner
(System.
in); System.
out.
print("Enter an integer n: ");
int n = scanner.nextInt();
scanner.close();
System.
out.
println("Output: " + factorial
(n
)); }
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwoKICAgY2xhc3MgRmFjdG9yaWFsIHsKCiAgICBwdWJsaWMgc3RhdGljIGxvbmcgZmFjdG9yaWFsKGludCBuKSB7CiAgICAgICAgbG9uZyByZXN1bHQgPSAxOwoKICAgICAgICBpZiAobiA8IDApIHsKICAgICAgICAgICAgcmV0dXJuIDE7CiAgICAgICAgfQoKICAgICAgICBmb3IgKGludCBpID0gMjsgaSA8PSBuOyBpKyspIHsKICAgICAgICAgICAgcmVzdWx0ICo9IGk7CiAgICAgICAgfQoKICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgfQoKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKICAgICAgICBTY2FubmVyIHNjYW5uZXIgPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwogICAgICAgIFN5c3RlbS5vdXQucHJpbnQoIkVudGVyIGFuIGludGVnZXIgbjogIik7CiAgICAgICAgCiAgICAgICAgaW50IG4gPSBzY2FubmVyLm5leHRJbnQoKTsKICAgICAgICBzY2FubmVyLmNsb3NlKCk7CgogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiT3V0cHV0OiAiICsgZmFjdG9yaWFsKG4pKTsgCiAgICB9Cn0=