Skip to content

Instantly share code, notes, and snippets.

@toantran-ea
Created January 8, 2020 12:10
Show Gist options
  • Save toantran-ea/761fe2f4267caaa1493ebcff2152a308 to your computer and use it in GitHub Desktop.
Save toantran-ea/761fe2f4267caaa1493ebcff2152a308 to your computer and use it in GitHub Desktop.
Tail Recursion function to solve Reachable Number problem
tailrec fun removeZeroes(x: Int): Int =
if (x % 10 == 0) removeZeroes(x / 10) else x
fun f(x: Int) = removeZeroes(x + 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment