Prime number
Practice
0 (0 votes)
Open
Open
Medium
Math basic
Basic math
Mathematics
Open
Math
Problem
23% Success 86 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given a large integer value \(n\). de the largest number \(x\) such that \(x \le n\) and all digits of \(x\) are prime.
Input format
Only line of input consists of a single integer denoting \(n\)
Output format
Print the required answer.
Constraints
\(1 \le Number \; of \; digits \; in \; n \le 10^{5} \)
No leading zeroes are available in \(n\)
\(n \ge 2\)
Sample Input
1000
Sample Output
777
Explanation
\(777\) is the largest number less than or equal to \( 1000\) having all it's digits prime.
Code Editor
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Submissions
Please login to view your submissions
Similar Problems
Points:50
13 votes
Tags:
MathematicsHardOpenApproved
Points:50
Tags:
HardRecruitNumber TheoryReadyGrammar-VerifiedMathematicsSimulationApprovedFactorization
Points:20
17 votes
Tags:
Data StructuresEasyGreedy Algorithmsapproved
Editorial
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor