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,
Kotlin,
Lisp,
Lisp (SBCL),
Lua,
Objective-C,
OCaml,
Octave,
Pascal,
Perl,
PHP,
Python,
Python 3,
R(RScript),
Racket,
Ruby,
Rust,
Scala,
Swift,
Visual Basic

Initializing Code Editor...

{"2acd6b1": "/pagelets/recommended-problems/algorithm/closest-gift/", "2acd66c": "/pagelets/suggested-problems/algorithm/closest-gift/", "2acd643": "/pagelets/show-submission/algorithm/closest-gift/", "2acd69b": "/pagelets/problems-hint/algorithm/closest-gift/", "2acd684": "/pagelets/problem-author-tester/algorithm/closest-gift/"}

{}

realtime.hackerearth.com

80

4443cdf206e25b3e79748e9d4ba441fd96f494a2

58a29e5cae2309f04b28

/realtime/pusher/auth/