You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

607 B

activebits

Instructions

Écrire une fonction, ActiveBits, qui retourne le nombre de bits actifs (bits ayant la valeur 1) dans la représentation binaire d'un nombre entier.

Fonction attendue

func ActiveBits(n int) uint {

}

Utilisation

Voici un éventuel programme pour tester votre fonction :

package main

import (
	"fmt"
	piscine ".."
)

func main() {
	nbits := piscine.ActiveBits(7)
	fmt.Println(nbits)
}

Et son résultat :

student@ubuntu:~/[[ROOT]]/test$ go build
student@ubuntu:~/[[ROOT]]/test$ ./test
3
student@ubuntu:~/[[ROOT]]/test$