Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get the negabinary representation of an integer
ResourceFunction["ToNegabinary"][n] gives the negabinary representation of the integer n. |
Get the representation for 17 in negabinary:
In[1]:= | ![]() |
Out[1]= | ![]() |
From this representation, recover the original integer:
In[2]:= | ![]() |
Out[2]= | ![]() |
Use the resource function FromNegabinary:
In[3]:= | ![]() |
Out[3]= | ![]() |
Some integers have the same representation in base 2:
In[4]:= | ![]() |
Out[4]= | ![]() |
ToNegabinary handles negative numbers:
In[5]:= | ![]() |
Out[5]= | ![]() |
Plot the negabinary representation for the first 22 integers:
In[6]:= | ![]() |
Out[6]= | ![]() |
A table of integers and their negabinary representations:
In[7]:= | ![]() |
Out[7]= | ![]() |
Numbers belonging to the Moser–de Bruijn sequence have identical binary and negabinary representations:
In[8]:= | ![]() |
In[9]:= | ![]() |
Out[9]= | ![]() |
In[10]:= | ![]() |
Out[10]= | ![]() |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License