TWINPR Editorial

PROBLEM LINK:

Practice
Contest

Author: Baban Gain
Editorialist: Baban Gain

DIFFICULTY:

CAKEWALK

PREREQUISITES:

High School Mathematics

PROBLEM:

For a given number N, find the count of occurance of N within twin primes.

EXPLANATION:

First of all for the given number N, check that if N is prime.
If N is composite there is no chance of being in twin primes.
It is to be noted that it is nowhere mentioned that the given number will be prime. :slight_smile:
If it is composite then print 0.
Else check if N-2 is prime, if it is, increment count by 1.
Then check if N+2 is prime, if it is, increment count by 1.
And print the result.

AUTHOR’S SOLUTIONS:

Click for Python
Click for C++
Click for Java

Please give the editorial for CALCMON.

Link- CodeChef: Practical coding for everyone.

Find it here CALCMON Editorial