Rotations of a number
This is a direct implementation of this answer https://math.stackexchange.com/a/1967330/92921
m = 308460277;
Reap[NestWhile[{#[[1]] - #[[2]] Sow@Floor[Divide @@ #]],
Floor[#[[2]]/10]} &, {m,
FromDigits@ConstantArray[1, Ceiling@Log[10, m]]} , #[[2]] >
0 &]][[2, 1]] // FromDigits
277614253
note this gives the 'closest' value for any input m
. You need to check that its correct:
Total@NestWhileList[ Floor[#/10] &, 277614253, # > 0 &]==m
True
I'm not sure of the etiquette re: reposting here vs giving code answers on the math site..
A ploddingly procedural implementation:
n = 308460277;
FromDigits[Reap[Do[{q, n} = QuotientRemainder[n, (10^k - 1)/9]; Sow[q],
{k, IntegerLength[n], 1, -1}]][[-1, 1]]]
277614253