Write a kotlin program to reverse a number.

Write a program to reverse a number using numeric operations. Below example shows how to reverse a number using numeric operations.


fun reverseNumber(number: Int): Int {
    var number = number

    var reverse = 0
    while (number != 0) {
        reverse = reverse * 10 + number % 10
        number = number / 10
    }
    return reverse
}


fun main(a: Array<String>) {
    var num = 12346598
    println("Original Number : " + num)
    println("Reversed Number : " + reverseNumber(num))
}


Output


Original Number : 12346598
Reversed Number : 89564321



Output


Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions