IntegerReverse
gives the integer whose digits are reversed with respect to those of the integer n.
IntegerReverse[n,b]
gives the integer whose digits in base b are reversed with respect to those of n.
IntegerReverse[n,b,len]
gives the integer with reversed digits after padding n with zeros on the left to have len digits.
Details
- IntegerReverse[n] always returns a positive integer.
- IntegerReverse[0,b,len] returns 0 for any base b and digits length len.
Examples
open allclose allBasic Examples (3)
Scope (5)
Reverse the base 10 digits of an integer:
Reverse the digits of an integer in a different base:
That is equivalent to this sequence of transformations:
Reverse the digits of an integer after padding with zeros on the left:
Reverse the digits of an integer using a mixed radix:
Applications (2)
Generate reversal permutations of degree bn:
Bit reversal permutations use base 2:
Reversal is involutive, therefore the permutations are all formed by 2-cycles:
This returns the first n numbers of the van der Corput sequence in base b:
The first 20 elements of the decimal van der Corput sequence:
The first 20 elements of the binary van der Corput sequence:
Properties & Relations (3)
Digit reversal strongly depends on the base used:
When the last digit of an integer is different from zero, IntegerReverse is its own inverse:
Otherwise, a different number is obtained:
Specify the number of digits in the second operation to obtain the original result:
Addition of an integer n and IntegerReverse[n] gives a palindromic number in some cases:
It is conjectured that this algorithm eventually produces a palindromic number for every decimal input:
There are numbers for which it is not known whether the algorithm succeeds, the smallest being 196:
Text
Wolfram Research (2015), IntegerReverse, Wolfram Language function, https://reference.wolfram.com/language/ref/IntegerReverse.html.
CMS
Wolfram Language. 2015. "IntegerReverse." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/IntegerReverse.html.
APA
Wolfram Language. (2015). IntegerReverse. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/IntegerReverse.html