Skip to content

Instantly share code, notes, and snippets.

@Deleplace
Created June 25, 2018 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Deleplace/7fd65fc65a678fb94e752001a1042c9e to your computer and use it in GitHub Desktop.
Save Deleplace/7fd65fc65a678fb94e752001a1042c9e to your computer and use it in GitHub Desktop.
Reads integers from stdin. How many of them verify (x % 8) == 5 ?
package main
import (
"fmt"
"io"
)
func main() {
var x, hits int
for {
_, err := fmt.Scan(&x)
if err == io.EOF {
break
}
if err != nil {
panic(err)
}
if x%8 == 5 {
hits++
}
}
fmt.Println(hits)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment