Re: number of digits in n^p
- To: mathgroup at smc.vnet.net
- Subject: [mg60474] Re: number of digits in n^p
- From: "Scout" <mathem at tica.org>
- Date: Sat, 17 Sep 2005 02:31:56 -0400 (EDT)
- References: <dgdu77$152$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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 yahoo.com> news:dgdu77$152$1 at smc.vnet.net... > > 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 >