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

Initializing Code Editor...

{"7f99c29": "/pagelets/problem-author-tester/algorithm/closest-gift/", "7f99c10": "/pagelets/suggested-problems/algorithm/closest-gift/", "7f99c40": "/pagelets/problems-hint/algorithm/closest-gift/", "7f99bea": "/pagelets/show-submission/algorithm/closest-gift/", "7f99c56": "/pagelets/recommended-problems/algorithm/closest-gift/"}

{}

realtime.hackerearth.com

80

4443cdf206e25b3e79748e9d4ba441fd96f494a2

58a29e5cae2309f04b28

/realtime/pusher/auth/