Suppose we have a number n. We have to check whether the product of (1*2*...*n) is divisible by (1+2+...+n) or not
So, if the input is like num = 5, then the output will be True as (1*2*3*4*5) = 120 and (1+2+3+4+5) = 15, and 120 is divisible by 15.
To solve this, we will follow these steps −
- if num + 1 is prime, then
- return false
- return true
Example
Let us see the following implementation to get better understanding −
def isPrime(num): if num > 1: for i in range(2, num): if num % i == 0: return False return True return False def solve(num): if isPrime(num + 1): return False return True num = 3 print(solve(num))
Input
5
Output
True