SOLVE

LATER

Closest Gift

Problem

Editorial

Analytics

You are on your way to find the gifts. All the gifts lie in your path in a straight line at prime numbers and your house is at 0.Given your current position find the closest gift to your position, and calculate the distance between your current position and gift and tell the distance.

Explanation

For the no.= 0, the output is 2.

The closest prime number to 0 is 2, so the answer is 2 - 0 = 2.

For number = 11, the output should be 0.

11 is a prime number, so the answer is 11 - 11 = 0.

**Input/Output**

[time limit] 3000ms [input] string number

**Constraints:**
0 ≤ int(number) ≤ 9 · 1014.

[output] integer

Time Limit:
3.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++,
Clojure,
C#,
D,
Erlang,
F#,
Go,
Groovy,
Haskell,
Java,
Java 8,
JavaScript(Rhino),
JavaScript(Node.js),
Lisp,
Lisp (SBCL),
Lua,
Objective-C,
OCaml,
Octave,
Pascal,
Perl,
PHP,
Python,
Python 3,
R(RScript),
Racket,
Ruby,
Rust,
Scala 2.11.8,
Swift,
Visual Basic

Initializing Code Editor...

{"fa9580b": "/pagelets/problem-author-tester/algorithm/closest-gift/", "fa957ce": "/pagelets/show-submission/algorithm/closest-gift/", "fa95836": "/pagelets/recommended-problems/algorithm/closest-gift/", "fa95821": "/pagelets/problems-hint/algorithm/closest-gift/", "fa957f3": "/pagelets/suggested-problems/algorithm/closest-gift/"}

{}

realtime.hackerearth.com

80

4443cdf206e25b3e79748e9d4ba441fd96f494a2

58a29e5cae2309f04b28

/realtime/pusher/auth/