mirror of https://github.com/01-edu/public.git
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.
27 lines
701 B
27 lines
701 B
6 years ago
|
## ispowerof2
|
||
|
|
||
|
### Instructions
|
||
6 years ago
|
|
||
5 years ago
|
Write a program that determines if a given number is a power of 2.
|
||
6 years ago
|
|
||
5 years ago
|
This program must print `true` if the given number is a power of 2, otherwise it prints `false`.
|
||
6 years ago
|
|
||
5 years ago
|
- If there is more than one or no argument the program should print nothing.
|
||
6 years ago
|
|
||
5 years ago
|
- When there is only one argument, it will always be a positive valid int.
|
||
6 years ago
|
|
||
5 years ago
|
### Usage :
|
||
5 years ago
|
|
||
|
```console
|
||
|
student@ubuntu:~/ispowerof2$ go build
|
||
|
student@ubuntu:~/ispowerof2$ ./ispowerof2 2 | cat -e
|
||
|
true$
|
||
5 years ago
|
student@ubuntu:~/ispowerof2$ ./ispowerof2 64
|
||
|
true
|
||
|
student@ubuntu:~/ispowerof2$ ./ispowerof2 513
|
||
|
false
|
||
5 years ago
|
student@ubuntu:~/ispowerof2$ ./ispowerof2
|
||
|
student@ubuntu:~/ispowerof2$ ./ispowerof2 64 1024
|
||
|
student@ubuntu:~/ispowerof2$
|
||
5 years ago
|
```
|