Factorial (function)#9547

Factorial (function)

1 second
64 megabytes
Medium

Determine if the factorial of a number, , is divisible by N^2.

The factorial, , is the product of all integers from to , expressed as N! = 1 \times 2 \times 3 \times \ldots \times N.

Implement the following function:

function Factorial(N: type): type; // Pascal

type Factorial(type x) // C++, C#, JAVA

def Factorial(x) // Python

This function should accept an integer (1 \le N \le 10^9) and return true if is divisible by N^2, otherwise return false.

type refers to the appropriate data type based on the language's requirements.

Examples:

If N = 3, 3! = 6, which is not divisible by . Therefore, the function should return false.

If N = 6, 6! = 720, which is divisible by . Thus, the function should return true.

Examples

Example 1

Loading
Loading

Example 4

Loading
Loading