TopCoder problem "TheLargestLuckyNumber" used in SRM 403 (Division II Level One)



Problem Statement

    

John thinks 4 and 7 are lucky digits, and all other digits are not lucky. A lucky number is a number that contains only lucky digits in decimal notation.

You are given an int n. Return the largest lucky number that is less than or equal to n.

 

Definition

    
Class:TheLargestLuckyNumber
Method:find
Parameters:int
Returns:int
Method signature:int find(int n)
(be sure your method is public)
    
 

Constraints

-n will be between 4 and 1,000,000, inclusive.
 

Examples

0)
    
100
Returns: 77
77 is the largest lucky number that is not greater than 100.
1)
    
75
Returns: 74
74 is the lucky number that immediately precedes 77.
2)
    
5
Returns: 4
The smallest lucky number is 4.
3)
    
474747
Returns: 474747
n is a lucky number.

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=8567

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=12175&pm=8567

Writer:

Vasyl[alphacom]

Testers:

PabloGilberto , Olexiy , marek.cygan , ivan_metelsky

Problem categories:

Simulation