Sobes.tech
Intern — Middle

Sequential output of numbers from 0 to 10

livecode

Task condition

Without changing the internal logic of the printNumber function, implement a program that sequentially outputs all integers from 0 to 10 inclusive, considering the built-in one-second pause.

package main

import (
    "fmt"
    "time"
)

func main() {
    for i := 0; i <= 10; i++ {
        printNumber(i)
    }
}

func printNumber(num int) {
    time.Sleep(time.Second)
    fmt.Println(num)
}