> it works if you use a python function:
>
> def z(x):
> return ((floor(log(x,10)))+1)*(1+x-((10^floor(log(x,10)
>
> for some reason it does not evaluate floor when evaluating symbolic
> functions.
This is because floor?? says that
#. If none of the above work, Sage returns a
On 10.04.2011 05:37, John Cremona wrote:
> The easiest way to get the number of digits of a positive integer n is
> len(str(n)) or even n.ndigits() !
>
> So
>
> sage: N=10^6
> sage: sum([n.ndigits() for n in srange(1,N+1)])
> 596
>
> solves your problem for all integers up to a million. Thi
The easiest way to get the number of digits of a positive integer n is
len(str(n)) or even n.ndigits() !
So
sage: N=10^6
sage: sum([n.ndigits() for n in srange(1,N+1)])
596
solves your problem for all integers up to a million. This is
obviously not the fastest way though!
John
On Apr 9, 6