Created
June 7, 2022 09:29
-
-
Save Husseinhj/8321c08000cf12b78e2451ed7e11c2c9 to your computer and use it in GitHub Desktop.
Palindrome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Kotlin code challenges. | |
* | |
*/ | |
fun main() { | |
println("${rev(465, 0)}") | |
} | |
fun rev(number: Int, temp: Int): Int { | |
if (number == 0) { | |
return temp | |
} | |
return rev(number / 10 , (temp * 10) + (number % 10)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment