I expect I can get length of decimal digit from function with given number input.
For example:
- $f(9)=1$
- $f(95)=2$
- $f(529)=3$
And so on...
What is the general form of $f(x)$?
I expect I can get length of decimal digit from function with given number input.
For example:
And so on...
What is the general form of $f(x)$?
Are you looking for $$f(x)=\lfloor\log_{10}x\rfloor+1$$
f(x)=floor(log(x)) + 1 is already simplified version from your answer.
– Muhammad Ikhwan Perwira
Sep 03 '22 at 05:46
If you have a positive integer $N$ represented in basis $B$, then the number of digits needed is exactly$\def\len{\operatorname{len}}$
$$\len_B(N)=1+\lfloor\log_B N\rfloor$$
where $\lfloor\,\cdot\,\rfloor$ denotes the floor function.
0 in function parameter so the function will return 1 digit? We know $log(0)$ is undefined in any base.
– Muhammad Ikhwan Perwira
Oct 29 '22 at 09:48
floor(log(x))+1is equivalent withfloor(log(x)+1)? – Muhammad Ikhwan Perwira Sep 03 '22 at 11:25