>>533
Haskell

https://ideone.com/QDxKsx

負の数とかは無視
f(x) = max { a×10ⁿ | a∈{1,2,5}, n∈ℤ, a×10ⁿ≦x }
を出力