Numbers ending with zeros are boring. They might be fun in your world, but not here. Get rid of them. Only the ending ones.
去處尾數的0
,也要考慮0
的狀況
1450 -> 145
960000 -> 96
1050 -> 105
-1050 -> -105
(ns noboringzeros.core)
(defn no-boring-zeros [n]
(if (= n 0)
0
(Integer. (clojure.string/replace (str n) #"0*$" ""))))
)
(ns noboringzeros.core)
(defn no-boring-zeros [n]
(if (= n 0)
0
(read-string (clojure.string/replace n #"0*$" "")))
)
(ns noboringzeros.core)
(defn no-boring-zeros [n]
(if (= n 0)
0
(Integer/parseInt (clojure.string/replace n #"0*$" "")))
)