Browse Source

review of ispowerof2 en and fr

pull/292/head
Christopher Fremond 5 years ago committed by Christopher Fremond
parent
commit
491cc468ef
  1. 10
      subjects/ispowerof2.en.md
  2. 27
      subjects/ispowerof2.fr.md

10
subjects/ispowerof2.en.md

@ -6,11 +6,11 @@ Write a program that determines if a given number is a power of 2.
This program must print `true` if the given number is a power of 2, otherwise it prints `false`.
- If there's no arguments passed to the program or there's more that one it shohuld print `\n`.
- If there is more than one or no argument the program should print a newline ("`\n`").
- In case of error you shoud handle it.
- Error cases have to be handled.
### Expected output :
### Usage :
```console
student@ubuntu:~/ispowerof2$ go build
@ -24,5 +24,7 @@ student@ubuntu:~/ispowerof2$ ./ispowerof2
student@ubuntu:~/ispowerof2$ ./ispowerof2 64 1024
student@ubuntu:~/ispowerof2$ ./ispowerof2 notanumber | cat -e
strconv.Atoi: parsing "a": invalid syntax$
student@ubuntu:~/ispowerof2$
```
```

27
subjects/ispowerof2.fr.md

@ -2,14 +2,29 @@
### Instructions
Écrire une fonction qui détermine si un nombre donné est une puissance de 2.
Écrire un programme fonction qui détermine si un nombre donné est une puissance de 2.
Cette fonction retourne `true` si le nombre donné est une puissance de 2, autrement elle retourne `false`.
Ce programme doit afficher `true` si le nombre donné est une puissance de 2, autrement il affiche `false`.
### Fonction attendue
- Si il y a plus d'un ou aucun argument le programme doit afficher un newline ("`\n`").
```go
func IsPowerOf2(n uint) bool {
- Les cas d'erreurs doivent être gérés.
}
### Utilisation :
```console
student@ubuntu:~/ispowerof2$ go build
student@ubuntu:~/ispowerof2$ ./ispowerof2 2 | cat -e
true$
student@ubuntu:~/ispowerof2$ ./ispowerof2 64 | cat -e
true$
student@ubuntu:~/ispowerof2$ ./ispowerof2 513 | cat -e
false$
student@ubuntu:~/ispowerof2$ ./ispowerof2
student@ubuntu:~/ispowerof2$ ./ispowerof2 64 1024
student@ubuntu:~/ispowerof2$ ./ispowerof2 notanumber | cat -e
strconv.Atoi: parsing "a": invalid syntax$
student@ubuntu:~/ispowerof2$
```

Loading…
Cancel
Save