Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

Re: balanced ternary arithmetic

  • To: mathgroup at smc.vnet.net
  • Subject: [mg31384] Re: [mg31376] balanced ternary arithmetic
  • From: Ken Levasseur <Kenneth_Levasseur at uml.edu>
  • Date: Wed, 31 Oct 2001 19:59:04 -0500 (EST)
  • References: <200110310831.DAA26481@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Karl:

I don't know of a package that does this, but here is code that I 
recently wrote for a course I'm teaching.  

Ken Levasseur
Math. Sci.
UMass Lowell

In[1]:=
tern[0]={0}; tern[1]={1};tern[-1]={-1};


In[2]:=
tern[k_]:=tern[k]=Join[ tern[Quotient[k,3,-1]],tern[Mod[k,3,-1]]]

In[3]:=
tern[2]

Out[3]=
{1, -1}

In[4]:=
tern[100]

Out[4]=
{1, 1, -1, 0, 1}

In[5]:=
tern[-32]

Out[5]=
{-1, -1, 1, 1}

Karl D'Adamo wrote:

>Does anyone know of any packages available that can express numbers in
>balanced ternary notation?  The BaseForm function can do regular base 3,
>but I want to use -1,0,1
>
>Thanks.
>
>
>




  • Prev by Date: Re: graphics on the same line
  • Next by Date: Re: weibull distribution
  • Previous by thread: balanced ternary arithmetic
  • Next by thread: Math LM