- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

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

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))

5

True

- Related Questions & Answers
- Sum of first N natural numbers which are divisible by X or Y
- Sum of first N natural numbers which are divisible by 2 and 7 in C++
- Number of pairs from the first N natural numbers whose sum is divisible by K in C++
- Count pairs of numbers from 1 to N with Product divisible by their Sum in C++
- Find if given number is sum of first n natural numbers in C++
- Sum of sum of first n natural numbers in C++
- Python Program for cube sum of first n natural numbers
- Sum of square-sums of first n natural numbers
- Python Program for Sum of squares of first n natural numbers
- Sum of first n natural numbers in C Program
- Sum of all subsets of a set formed by first n natural numbers
- Sum of squares of first n natural numbers in C Program?
- C Program for cube sum of first n natural numbers?
- C++ Program for cube sum of first n natural numbers?
- Java Program to cube sum of first n natural numbers

Advertisements