public/subjects/activebits/README.md

39 lines
466 B
Markdown
Raw Permalink Normal View History

## activebits
### Instructions
2019-07-01 21:46:32 +00:00
Write a function, `ActiveBits`, that returns the number of active `bits` (bits with the value 1) in the binary representation of an integer number.
### Expected function
```go
func ActiveBits(n int) int {
}
```
### Usage
2020-02-25 12:02:16 +00:00
Here is a possible program to test your function :
```go
package main
import (
2019-04-24 14:18:40 +00:00
"fmt"
"piscine"
)
func main() {
2020-05-17 19:01:54 +00:00
fmt.Println(piscine.ActiveBits(7))
}
```
And its output :
```console
$ go run .
2019-06-19 14:16:18 +00:00
3
$
```