Hi,
I am trying to count the number of digits in a number in Clojure as follows: I get a StackOverflowError even for 2 digit numbers
(defn num-digits [n]
(if (= 0 n)
0
(inc (num-digits (/ n 10)))))
(println (num-digits 93))
But if I replace / with unchecked-divide then it works for at least 93. But neither of the techniques works for:
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
First, I would like to know how to perform division the C-style in Clojure. Whenever I do (/ x y) I get a Ratio and not a Integer. What is the way to do it?
Secondly, is there a way API to convert this Number into a vector of digits and call count on it.
Thanks,
Ajay G