Countdown

Count down from 5 to 1 using a for loop with i--.

package main

import "fmt"

func main() {
	for i := 5; i >= 1; i-- {
		fmt.Println(i)
	}
	fmt.Println("Go!")
}
▶ Open Go Playground

Copy the code above and paste to run

© 2026 ByteLearn.dev. Free courses for developers. · Privacy