Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2014

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

Search the Archive

Re: Goodstein expansion

  • To: mathgroup at
  • Subject: [mg132325] Re: Goodstein expansion
  • From: Bill Rowe <readnews at>
  • Date: Sun, 9 Feb 2014 04:49:07 -0500 (EST)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:

On 2/8/14 at 4:02 AM, Roberto.Brambilla at (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


>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


>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}


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}


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

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

  • Prev by Date: Re: Goodstein expansion
  • Next by Date: Re: Memory leaks problem
  • Previous by thread: Re: Goodstein expansion
  • Next by thread: R: Re: Goodstein expansion