Go programming tutorials
Write your first Go program, work with slices and maps, then build an inventory tool that checks each delivery and shipment.
Go core curriculum
Getting started
Decisions and loops
Functions and data
Files and projects
Reverse the digits of a number
package main
import (
"fmt"
"strconv"
)
func main() {
input := 123
output := 0
temp := input
for temp > 0 {
remainder := temp % 10
output *= 10
output += remainder
temp /= 10
}
fmt.Println("Original Number : " + strconv.Itoa(input))
fmt.Println("Reverse Number : " + strconv.Itoa(output))
}
Original Number : 123 Reverse Number : 321