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.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
F#
while
loop on compile)i % 10
gets the right-most digit ofi
rev * 10
shifts the numbers left, with right-most zeroi / 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.