Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #16546
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed1.swip.net!uio.no!newspump.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail |
|---|---|
| From | Bill Rowe <readnews@sbcglobal.net> |
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Goodstein expansion |
| Date | Sun, 9 Feb 2014 09:46:34 +0000 (UTC) |
| Sender | steve@smc.vnet.net |
| Approved | Steven M. Christensen <steve@smc.vnet.net>, Moderator |
| Message-ID | <ld7ipq$e75$1@smc.vnet.net> (permalink) |
| Lines | 49 |
| Organization | Time-Warner Telecom |
| NNTP-Posting-Date | 09 Feb 2014 09:51:58 GMT |
| NNTP-Posting-Host | 82465e83.news.twtelecom.net |
| X-Trace | DXC=cVD@1TC9keZ]VA;Pm`8_TYC_A=>8kQj6];[h;PUXBgbTfTF>IWQi=<\EFiONJ7[GoVn8TYLIE51fU |
| X-Complaints-To | abuse@twtelecom.net |
| Xref | csiph.com comp.soft-sys.math.mathematica:16546 |
Show key headers only | 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
Re: Goodstein expansion Bill Rowe <readnews@sbcglobal.net> - 2014-02-09 09:46 +0000
csiph-web