Created
May 14, 2022 16:50
-
-
Save jtprogru/b57feea847b7b6c8d04aba1dd1239339 to your computer and use it in GitHub Desktop.
По данному числу N распечатайте все целые значения степени двойки, не превосходящие N, в порядке возрастания. Вводится натуральное число. Выведите ответ на задачу.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func main() { | |
var n int | |
var outputStr string | |
_, _ = fmt.Scan(&n) | |
for i := 0; i <= n; i++ { | |
x := int(math.Exp2(float64(i))) | |
if x > n { | |
break | |
} | |
outputStr += fmt.Sprintf("%d ", x) | |
} | |
fmt.Println(outputStr) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment