Answer the question
In order to leave comments, you need to log in
Why doesn't for work in golang?
I can't figure out why the code doesn't work. Namely, why the for loop does not work, in theory the condition turns out to be "while i is more than one - do ...."
if you compile and run the code, it simply asks you to enter a number and finishes its work.
package main
import "fmt"
func main() {
var number int
fmt.Println("Enter number: ")
fmt.Scanf("%i",&number)
for i:=number; i>1; i-- {
fmt.Println(i)
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question