Prime numbers, especially in the realm of single digits, present captivating patterns. One such pattern is the existence of only one even prime digit. Given an input number, your task is to identify if it contains this unique even prime digit.
Boundary Condition(s):
1 <= Number <= 10^9
Input Format:
The input is a single integer.
Output Format:
The output should display “Contains Even Prime” if the number has the digit 2, otherwise “Does Not Contain Even Prime”.
Example Input/Output 1:
Input:
12345
Output:
Contains Even Prime
Explanation:
The number 12345 contains the digit 2, which is the only even prime.
Example Input/Output 2:
Input:
13579
Output:
Does Not Contain Even Prime
Explanation:
The number 13579 does not contain the digit 2.
number = input()
if '2' in number:
print("Contains Even Prime")
else:
print("Does Not Contain Even Prime")
#include<stdio.h>
#include<string.h>
int main() {
char number[10];
scanf("%s", number);
if(strchr(number, '2'))
printf("Contains Even Prime");
else
printf("Does Not Contain Even Prime");
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main() {
string number;
cin >> number;
if(number.find('2') != string::npos)
cout << "Contains Even Prime";
else
cout << "Does Not Contain Even Prime";
return 0;
}
import java.util.Scanner;
public class EvenPrimeChecker {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String number = sc.next();
if(number.contains("2"))
System.out.println("Contains Even Prime");
else
System.out.println("Does Not Contain Even Prime");
}
}