Go: Added count
This commit is contained in:
parent
3ca928243e
commit
bc068f3dc1
BIN
go/count/count
Executable file
BIN
go/count/count
Executable file
Binary file not shown.
6
go/count/doc.go
Normal file
6
go/count/doc.go
Normal file
@ -0,0 +1,6 @@
|
||||
// count project doc.go
|
||||
|
||||
/*
|
||||
count document
|
||||
*/
|
||||
package main
|
29
go/count/main.go
Normal file
29
go/count/main.go
Normal file
@ -0,0 +1,29 @@
|
||||
// count project main.go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
total := 0
|
||||
|
||||
fmt.Printf("First we want to print 1-100 with a for loop\n")
|
||||
fmt.Printf("Then We will try to count down recursevly.")
|
||||
for i := 0; i < 101; i++ {
|
||||
fmt.Println(i)
|
||||
total = i
|
||||
}
|
||||
recCount(total)
|
||||
|
||||
}
|
||||
|
||||
func recCount(seed int) {
|
||||
fmt.Println(seed)
|
||||
if seed == 0 {
|
||||
return
|
||||
} else {
|
||||
recCount(seed - 1)
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user