Factorial (function)
Medium
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Determine if the factorial of a number, N!, is divisible by N^2
.
The factorial, N!, is the product of all integers from 1 to N, expressed as N! = 1 * 2 * 3 * ... * N.
Implement the following function:
Pascal:
function Factorial(N: type): type;
C++, C#, JAVA:
type Factorial(type x)
Python:
def Factorial(x)
This function should accept an integer N (1 ≤ N ≤ 10^9
) and return true if N! is divisible by N^2
, otherwise return false.
type refers to the appropriate data type based on the language's requirements.
Examples:
For N = 3, 3! = 6, which is not divisible by 9. Therefore, the function should return false.
For N = 6, 6! = 720, which is divisible by 36. Thus, the function should return true.
Examples
Input #1
Answer #1
Input #4
Answer #4
Submissions 2K
Acceptance rate 8%