Lucky Digits and Modulo
Practice
4 (155 votes)
Mathematics
Lucky Digit
Easy
Simple Math
Problem
64% Success 5210 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Given a number N find out the minimum number M such that result of N modulo M become either 4 or 7.
Input:
First line of input contains number of test cases T. Each test case contains a single integer N.
Output:
Print the minimum value of M such that result of N%M become either 4 or 7 if there is no any value of M exists then print -1.
Constraints:
1 <= T <= 103
1 <= N <= 109
Submissions
Please login to view your submissions
Similar Problems
Points:20
4 votes
Tags:
Special NumbersCountingImplementationMath BasicBasic ProgrammingBasic MathBasics of ImplementationSieveMath
Points:20
7 votes
Tags:
Dynamic ProgrammingRecursionAlgorithmsEasyMathematicsOpenApproved
Points:20
21 votes
Tags:
Bit manipulationBasic ProgrammingApprovedEasyBit manipulation
Editorial