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
100
Returns: 77
77 is the largest lucky number that is not greater than 100.75
Returns: 74
74 is the lucky number that immediately precedes 77.5
Returns: 4
The smallest lucky number is 4.474747
Returns: 474747
n is a lucky number.