Lucky Digits and Modulo
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 <= 10^{3}
1 <= N <= 10^{9}
Explanation
Test Case #1:
For N=9, minimum value of M will be 5.
Time Limit:
1.0 sec(s)
for each input file.
Memory Limit:
256 MB
Source Limit:
1024 KB
Marking Scheme:
Marks are awarded when all the testcases pass.
Allowed Languages:
C,
C++,
C++14,
Clojure,
C#,
D,
Erlang,
F#,
Go,
Groovy,
Haskell,
Java,
Java 8,
JavaScript(Rhino),
JavaScript(Node.js),
Julia,
Kotlin,
Lisp,
Lisp (SBCL),
Lua,
Objective-C,
OCaml,
Octave,
Pascal,
Perl,
PHP,
Python,
Python 3,
R(RScript),
Racket,
Ruby,
Rust,
Scala,
Swift,
Swift-4.1,
Visual Basic