Statistics

Problem Statement for "TheLargestLuckyNumber"

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

  1. 100

    Returns: 77

    77 is the largest lucky number that is not greater than 100.

  2. 75

    Returns: 74

    74 is the lucky number that immediately precedes 77.

  3. 5

    Returns: 4

    The smallest lucky number is 4.

  4. 474747

    Returns: 474747

    n is a lucky number.

  5. 1000000

    Returns: 777777

  6. 45

    Returns: 44

  7. 71

    Returns: 47

  8. 38

    Returns: 7

  9. 4

    Returns: 4

  10. 73

    Returns: 47

  11. 1041

    Returns: 777

  12. 1467

    Returns: 777

  13. 1334

    Returns: 777

  14. 1500

    Returns: 777

  15. 1169

    Returns: 777

  16. 100041

    Returns: 77777

  17. 118467

    Returns: 77777

  18. 106334

    Returns: 77777

  19. 126500

    Returns: 77777

  20. 119169

    Returns: 77777

  21. 900041

    Returns: 777777

  22. 918467

    Returns: 777777

  23. 906334

    Returns: 777777

  24. 926500

    Returns: 777777

  25. 919169

    Returns: 777777

  26. 447749

    Returns: 447747

  27. 477

    Returns: 477

  28. 747800

    Returns: 747777

  29. 777444

    Returns: 777444

  30. 444777

    Returns: 444777

  31. 747473

    Returns: 747447

  32. 747475

    Returns: 747474

  33. 747479

    Returns: 747477

  34. 27

    Returns: 7

  35. 686886

    Returns: 477777

  36. 234908

    Returns: 77777

  37. 44

    Returns: 44

  38. 57

    Returns: 47

  39. 70

    Returns: 47

  40. 433

    Returns: 77

  41. 9800

    Returns: 7777

  42. 11

    Returns: 7

  43. 432345

    Returns: 77777

  44. 147

    Returns: 77

  45. 4274

    Returns: 777

  46. 900005

    Returns: 777777

  47. 9801

    Returns: 7777

  48. 55555

    Returns: 47777

  49. 72

    Returns: 47


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: