F#

let rec loop rev i = if i = 0 then rev else loop (rev * 10 + (i % 10)) (i / 10) // usage, returns 987654321 let reversed = loop 0 123456789

while

i % 10

i

rev * 10

i / 10

I happened to remember these little number tricks from a previous challenge. This is basically using integers as digit stacks.

We're a place where coders share, stay up-to-date and grow their careers.

We strive for transparency and don't collect excess data.

## re: Daily Coding Puzzles - Oct 29th - Nov 2nd VIEW POST

TOP OF THREAD FULL DISCUSSIONF#

(F# will TCO to a`while`

loop on compile)`i % 10`

gets the right-most digit of`i`

`rev * 10`

shifts the numbers left, with right-most zero`i / 10`

shifts the numbers right, dropping right-most digitI happened to remember these little number tricks from a previous challenge. This is basically using integers as digit stacks.