Mathematica, no modulo!
n = 14627;
length = Ceiling[Log[10, n]];
img = Rasterize[n, RasterSize -> 400, ImageSize -> 400];
box = Rasterize[n, "BoundingBox", RasterSize -> 400, ImageSize -> 400];
width = box[[1]]; height = box[[3]];
ToExpression[
TextRecognize[
ImageAssemble[
ImageTake[img, {1, height}, #] & /@
NestList[# - width/length &, {width - width/length, width},
length - 1]]]]
Let's break it down.
First we use some "creative arithmetics" to find out how many digits are in the number: length = Ceiling[Log[10, n]];
Next, we Rasterize the number to a nice large image:
Now we query for the bounding box of that image, and populate the width and height (actually using the baseline offset instead of the image height, because MM adds some whitespace below the baseline in the image).
Next, NestList recursively subtracts the width of the image divided by the length of the string to enable ImageTake to pluck characters from the end of the image one by one, and those are reassembled by ImageAssemble to this image:
Then we pass that on to the TextRecognize function for optical character recognition, which at this image size and rasterization quality is able to impeccably recognize the final output and give us the integer:
72641
Logarithms and OCR - It's like chocolate and peanut butter!
New and improved
This version pads out the number to deal with the obstinate behavior of TextRecognize with small numbers, and then subtracts out the pad at the end. This even works for single-digit numbers!
Though, why you would run a reverse routine on a single number is a mystery to me. But just for the sake of completeness, I even made it work for inputs of zero and one, which would normally break because the floored log doesn't return 1 for them.
n = 1;
pad = 94949;
length = If[n == 1 || n == 0, 1, Ceiling[Log[10, n]]];
img = Rasterize[n + (pad*10^length), RasterSize -> 400,
ImageSize -> 400];
padlength = length + 5;
box = ImageDimensions[img];
width = box[[1]]; height = box[[2]];
reversed =
ImageResize[
ImageAssemble[
ImageTake[img, {1, height}, #] & /@
NestList[# - width/padlength &, {width + 1 - width/padlength,
width}, padlength - 1]], 200];
recognized = ToExpression[TextRecognize[reversed]];
(recognized - pad)/10^5
1230
is the input? Are we allowed to output321
? (Otherwise, Strings are necessary). \$\endgroup\$