Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #16546

Re: Goodstein expansion

From Bill Rowe <readnews@sbcglobal.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Goodstein expansion
Date 2014-02-09 09:46 +0000
Message-ID <ld7ipq$e75$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


On 2/8/14 at 4:02 AM, Roberto.Brambilla@rse-web.it (Brambilla Roberto
Luigi (RSE)) wrote:

>The Goodstein expansion of integers  (see for instance  Stillwell,"
>Roads to Infinity", pag.47)

>Given an integer n we can write it as sum of powers of  2

>87=2^6+2^4+2^2+1=2^(2^2+2)+2^(2^2)+2^2+2^0

>More generally assuming an integer b as a base, we can write  n as a
>sum of power of b with coefficients <b es.:  b=5

>87=3*5^2+2*5^1+2*5^0.

>I can do it by means of a long and obvious routine with lots 
>of If[]  and While[]. May be someone can do it by means of the
>recursive properties of Mathematica language?

Since this is nothing more than expressing an integer in a
different base, built in functions will do what you want

That is

In[1]:= IntegerDigits[87, 5]

Out[1]= {3,2,2}

and

In[2]:= IntegerDigits[87, 2]

Out[2]= {1,0,1,0,1,1,1}

And if you want a list of powers for the base

In[3]:= d = IntegerDigits[87, 2];
Pick[Range[Length@d] - 1, Unitize[Reverse@d], 1]

Out[4]= {0,1,2,4,6}

and

In[5]:= d = IntegerDigits[87, 5];
Pick[Range[Length@d] - 1, Unitize[Reverse@d], 1]

Out[6]= {0,1,2}

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar


Thread

Re: Goodstein expansion Bill Rowe <readnews@sbcglobal.net> - 2014-02-09 09:46 +0000

csiph-web