IntegerReverse

IntegerReverse[n]

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

Examples

open allclose all

Basic Examples  (3)

Reverse the digits of an integer:

Reverse the binary digits of an integer:

The result coincides with the input because that number is a binary palindrome:

Reverse the digits of an integer after padding it with zeros on the left:

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:

That is equivalent to this sequence of transformations:

Reverse the respective digits of a list of integers:

Applications  (2)

Generate reversal permutations of degree bn:

Bit reversal permutations use base 2:

Use base 3:

Reversal is involutive, therefore the permutations are all formed by 2-cycles:

Represent those swaps:

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:

Show how it progressively fills the interval from 0 to 1:

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:

But not always:

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:

Wolfram Research (2015), IntegerReverse, Wolfram Language function, https://reference.wolfram.com/language/ref/IntegerReverse.html.

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

BibTeX

@misc{reference.wolfram_2024_integerreverse, author="Wolfram Research", title="{IntegerReverse}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/IntegerReverse.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_integerreverse, organization={Wolfram Research}, title={IntegerReverse}, year={2015}, url={https://reference.wolfram.com/language/ref/IntegerReverse.html}, note=[Accessed: 21-November-2024 ]}