Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: number of digits in n^p

  • To: mathgroup at
  • Subject: [mg60474] Re: number of digits in n^p
  • From: "Scout" <mathem at>
  • Date: Sat, 17 Sep 2005 02:31:56 -0400 (EDT)
  • References: <dgdu77$152$>
  • Sender: owner-wri-mathgroup at

Hi George,
if you don't want to use DigitCount[] command (eg. Total[DigitCount[n^b]] or 
Plus@@DigitCount[n^b] ),
let's suppose that d is the number of digits in n^b then n^b = a*10^d where 
0.1 <= a < 1.
Taking the log base 10 of both sides of the equation and solving in d
we get  d = b*log(n) - log(a) where -1 <= log(a) < 0. Thus, since d is an 
integer, truncate b*log(n) to an integer and add 1.

In Mathematica we can write:
In[1]:= f[n_Integer, b_Integer]:= IntegerPart[b Log[10,n]]+1 /; n>0&&b>0
In[2]:= f[67,89]
Out[2]= 163

    ~ Scout ~

"George" <orangepi77 at>  news:dgdu77$152$1 at
> i wonder if there is a formula, a function, or a method in mathematica to 
> know the number of digits in  n raised to the power of p without 
> calculating the result, such as 67^89 will give us a number with 163 
> digits in it, is there a way to know this result without actually 
> calculating 67^89
> thanks
> George

  • Prev by Date: Re: Complete solution to a modular System of equations
  • Next by Date: Extracting coefficients for sinusoidals
  • Previous by thread: Re: number of digits in n^p
  • Next by thread: Re: number of digits in n^p