Does it divide?
Practice
3.9 (114 votes)
Easy
Math
Number theory
Primality test
Problem
89% Success 41930 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code
Consider a permutation of numbers $$1$$ to $$N$$ written on a paper. Let’s denote the product of its element as $$P$$ and the sum of its elements as $$S$$. Given a positive integer $$N$$, your task is to determine whether $$P$$ is divisible by $$S$$ or not.
Input Format
There will be multiple test cases, each input will start with an integer $$T$$ $$(1 \leq T \leq 100)$$, number of test cases.
Each test case will contain an integer $$N$$ $$(1 \leq N \leq 10^9)$$, length of the permutation.
Output Format
For each test case, print “YES” if $$P$$ is divisible by $$S$$, otherwise print “NO”.
Submissions
Please login to view your submissions
Similar Problems
Points:20
22 votes
Tags:
ApprovedEasyMathOpenPrimality test
Points:20
8 votes
Tags:
ApprovedEasyHiringMathPrimality testSieve
Points:20
17 votes
Tags:
EasyGrammar-VerifiedMathNumber TheoryPrimality testPrime number
Editorial