Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Compute the digit in a given place of the positional representation of a number
ResourceFunction["NthDigit"][x,n] returns the nth base-10 digit of x. | |
ResourceFunction["NthDigit"][x,n,base] returns the nth digit of x in the specified base. |
Compute the nth digit of a given number:
In[1]:= |
Out[1]= |
Give the 2500th digit of π in base 10:
In[2]:= |
Out[2]= |
Compute the base-10 digits of a number less than 1:
In[3]:= |
Out[3]= |
Give the first 10 digits of 19/7 in base 3:
In[4]:= |
Out[4]= |
Noninteger bases are allowed:
In[5]:= |
Out[5]= |
Compute the number of 1s in the first 10^4 binary digits of π:
In[6]:= |
Out[6]= |
Plot the distribution of first 10,000 digits of π in base 47:
In[7]:= |
Out[7]= |
NthDigit ignores the sign of its first argument:
In[8]:= |
Out[8]= |
NthDigit gives Indeterminate if more digits than the precision are requested:
In[9]:= |
Out[9]= |
In[10]:= |
Out[10]= |
Positional representations only work for bases greater than 1. Using an unsuitable base triggers a message:
Out[10]= |
This work is licensed under a Creative Commons Attribution 4.0 International License